Add loot tables for blocks, copy over energy.
This commit is contained in:
@@ -4,7 +4,6 @@ import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.util.BlockUtils;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
// TODO DROPS
|
||||
public class MachineCasingBlock extends Block {
|
||||
public MachineCasingBlock() {
|
||||
super(BlockUtils.DEFAULT_ROCK_PROPERTIES);
|
||||
|
@@ -4,7 +4,6 @@ import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.util.BlockUtils;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
// TODO DROPS
|
||||
public class QuartzEnrichedIronBlock extends Block {
|
||||
public QuartzEnrichedIronBlock() {
|
||||
super(BlockUtils.DEFAULT_ROCK_PROPERTIES);
|
||||
|
@@ -1,48 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.integration.forgeenergy;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.energy.EnergyStorage;
|
||||
|
||||
public class ItemEnergyForge extends EnergyStorage {
|
||||
private static final String NBT_ENERGY = "Energy";
|
||||
|
||||
private ItemStack stack;
|
||||
|
||||
public ItemEnergyForge(ItemStack stack, int capacity) {
|
||||
super(capacity, Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
|
||||
this.stack = stack;
|
||||
this.energy = stack.hasTag() && stack.getTag().contains(NBT_ENERGY) ? stack.getTag().getInt(NBT_ENERGY) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(int maxReceive, boolean simulate) {
|
||||
int received = super.receiveEnergy(maxReceive, simulate);
|
||||
|
||||
if (received > 0 && !simulate) {
|
||||
if (!stack.hasTag()) {
|
||||
stack.setTag(new CompoundNBT());
|
||||
}
|
||||
|
||||
stack.getTag().putInt(NBT_ENERGY, getEnergyStored());
|
||||
}
|
||||
|
||||
return received;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate) {
|
||||
int extracted = super.extractEnergy(maxExtract, simulate);
|
||||
|
||||
if (extracted > 0 && !simulate) {
|
||||
if (!stack.hasTag()) {
|
||||
stack.setTag(new CompoundNBT());
|
||||
}
|
||||
|
||||
stack.getTag().putInt(NBT_ENERGY, getEnergyStored());
|
||||
}
|
||||
|
||||
return extracted;
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package com.raoulvdberge.refinedstorage.integration.forgeenergy;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.common.util.INBTSerializable;
|
||||
import net.minecraftforge.energy.EnergyStorage;
|
||||
|
||||
public class ItemEnergyStorage extends EnergyStorage implements INBTSerializable<CompoundNBT> {
|
||||
private static final String NBT_ENERGY = "Energy";
|
||||
|
||||
public ItemEnergyStorage(ItemStack stack, int capacity) {
|
||||
super(capacity, Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
|
||||
this.energy = stack.hasTag() && stack.getTag().contains(NBT_ENERGY) ? stack.getTag().getInt(NBT_ENERGY) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT serializeNBT() {
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
|
||||
tag.putInt(NBT_ENERGY, getEnergyStored());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(CompoundNBT tag) {
|
||||
this.energy = tag.getInt(NBT_ENERGY);
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
package com.raoulvdberge.refinedstorage.item;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.item.capabilityprovider.CapabilityProviderEnergy;
|
||||
import com.raoulvdberge.refinedstorage.item.capabilityprovider.EnergyCapabilityProvider;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -31,7 +31,7 @@ public abstract class EnergyItem extends Item {
|
||||
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT tag) {
|
||||
return new CapabilityProviderEnergy(stack, energyCapacity);
|
||||
return new EnergyCapabilityProvider(stack, energyCapacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -4,6 +4,7 @@ import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.block.ControllerBlock;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
// TODO: Set energy state on controller item texture...
|
||||
public class ControllerBlockItem extends EnergyBlockItem {
|
||||
public ControllerBlockItem(ControllerBlock block) {
|
||||
super(block, new Item.Properties().group(RS.MAIN_GROUP).maxStackSize(1), block.getType() == ControllerBlock.Type.CREATIVE, () -> RS.CONFIG.getController().getCapacity());
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.raoulvdberge.refinedstorage.item.blockitem;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.item.capabilityprovider.CapabilityProviderEnergy;
|
||||
import com.raoulvdberge.refinedstorage.item.capabilityprovider.EnergyCapabilityProvider;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.BlockItem;
|
||||
@@ -34,7 +34,7 @@ public abstract class EnergyBlockItem extends BlockItem {
|
||||
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT tag) {
|
||||
return new CapabilityProviderEnergy(stack, energyCapacity.get());
|
||||
return new EnergyCapabilityProvider(stack, energyCapacity.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package com.raoulvdberge.refinedstorage.item.blockitem;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.block.BlockBase;
|
||||
import com.raoulvdberge.refinedstorage.item.capabilityprovider.CapabilityProviderEnergy;
|
||||
import com.raoulvdberge.refinedstorage.item.capabilityprovider.EnergyCapabilityProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
@@ -23,7 +23,7 @@ public abstract class ItemBlockEnergyItem extends ItemBlockBase {
|
||||
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT tag) {
|
||||
return new CapabilityProviderEnergy(stack, energyCapacity);
|
||||
return new EnergyCapabilityProvider(stack, energyCapacity);
|
||||
}
|
||||
/* TODO
|
||||
@Override
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.raoulvdberge.refinedstorage.item.capabilityprovider;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.integration.forgeenergy.ItemEnergyForge;
|
||||
import com.raoulvdberge.refinedstorage.integration.forgeenergy.ItemEnergyStorage;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
@@ -12,12 +12,12 @@ import net.minecraftforge.energy.IEnergyStorage;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class CapabilityProviderEnergy implements ICapabilityProvider {
|
||||
public class EnergyCapabilityProvider implements ICapabilityProvider {
|
||||
private ItemStack stack;
|
||||
private int energyCapacity;
|
||||
private LazyOptional<IEnergyStorage> capability = LazyOptional.of(() -> new ItemEnergyForge(stack, energyCapacity));
|
||||
private LazyOptional<IEnergyStorage> capability = LazyOptional.of(() -> new ItemEnergyStorage(stack, energyCapacity));
|
||||
|
||||
public CapabilityProviderEnergy(ItemStack stack, int energyCapacity) {
|
||||
public EnergyCapabilityProvider(ItemStack stack, int energyCapacity) {
|
||||
this.stack = stack;
|
||||
this.energyCapacity = energyCapacity;
|
||||
}
|
@@ -221,6 +221,7 @@ public class ControllerTile extends TileBase implements ITickableTileEntity, INe
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (type == ControllerBlock.Type.NORMAL) {
|
||||
if (!RS.CONFIG.getController().getUseEnergy()) {
|
||||
this.energy.setStored(this.energy.getCapacity());
|
||||
@@ -231,7 +232,8 @@ public class ControllerTile extends TileBase implements ITickableTileEntity, INe
|
||||
}
|
||||
} else if (type == ControllerBlock.Type.CREATIVE) {
|
||||
this.energy.setStored(this.energy.getCapacity());
|
||||
}
|
||||
}*/
|
||||
this.energy.setStored(5000);
|
||||
|
||||
boolean canRun = canRun();
|
||||
|
||||
|
@@ -1,6 +1,82 @@
|
||||
{
|
||||
"parent": "refinedstorage:block/cube_all_cutout",
|
||||
"parent": "block/cube",
|
||||
"elements": [
|
||||
{
|
||||
"from": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"to": [
|
||||
16,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"faces": {
|
||||
"down": {
|
||||
"texture": "#all",
|
||||
"cullface": "down"
|
||||
},
|
||||
"up": {
|
||||
"texture": "#all",
|
||||
"cullface": "up"
|
||||
},
|
||||
"north": {
|
||||
"texture": "#all",
|
||||
"cullface": "north"
|
||||
},
|
||||
"south": {
|
||||
"texture": "#all",
|
||||
"cullface": "south"
|
||||
},
|
||||
"west": {
|
||||
"texture": "#all",
|
||||
"cullface": "west"
|
||||
},
|
||||
"east": {
|
||||
"texture": "#all",
|
||||
"cullface": "east"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"to": [
|
||||
16,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"faces": {
|
||||
"up": {
|
||||
"texture": "#cutout",
|
||||
"cullface": "up"
|
||||
},
|
||||
"down": {
|
||||
"texture": "#cutout",
|
||||
"cullface": "down"
|
||||
},
|
||||
"north": {
|
||||
"texture": "#cutout",
|
||||
"cullface": "north"
|
||||
},
|
||||
"south": {
|
||||
"texture": "#cutout",
|
||||
"cullface": "south"
|
||||
},
|
||||
"west": {
|
||||
"texture": "#cutout",
|
||||
"cullface": "west"
|
||||
},
|
||||
"east": {
|
||||
"texture": "#cutout",
|
||||
"cullface": "east"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
0,
|
||||
|
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "refinedstorage:controller",
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:copy_nbt",
|
||||
"source": "block_entity",
|
||||
"ops": [
|
||||
{
|
||||
"source": "Energy",
|
||||
"target": "Energy",
|
||||
"op": "replace"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "minecraft:set_contents",
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:dynamic",
|
||||
"name": "minecraft:contents"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "refinedstorage:machine_casing"
|
||||
}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "refinedstorage:quartz_enriched_iron_block"
|
||||
}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user