Added a fully charged regular Controller to the creative menu. The Controller item now shows a durability bar for the energy.

This commit is contained in:
raoulvdberge
2018-07-11 13:53:20 +02:00
parent bbff51a09e
commit ddb89f5ae5
5 changed files with 54 additions and 20 deletions

View File

@@ -22,6 +22,8 @@ NOTE: Worlds that used Refined Storage 1.5.x are fully compatible with Refined S
- Added config option to configure controller max receive rate (samtrion) - Added config option to configure controller max receive rate (samtrion)
- Added config option to configure energy capacity of Refined Storage items (raoulvdberge) - Added config option to configure energy capacity of Refined Storage items (raoulvdberge)
- Added config option to change Reader / Writer channel energy capacity (raoulvdberge) - Added config option to change Reader / Writer channel energy capacity (raoulvdberge)
- Added a fully charged regular Controller to the creative menu (raoulvdberge)
- The Controller item now shows a durability bar for the energy (raoulvdberge)
- Changed fluid storage progression to be 64k - 256k - 1024k - 4096k (raoulvdberge) - Changed fluid storage progression to be 64k - 256k - 1024k - 4096k (raoulvdberge)
- You can no longer put a Filter in filter slots to gain additional filter slots (raoulvdberge) - You can no longer put a Filter in filter slots to gain additional filter slots (raoulvdberge)
- You can now re-insert Processing Patterns in the Pattern Grid and have the inputs and outputs be completed (raoulvdberge) - You can now re-insert Processing Patterns in the Pattern Grid and have the inputs and outputs be completed (raoulvdberge)

View File

@@ -109,7 +109,9 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
if (!controller.getPos().equals(otherControllerPos)) { if (!controller.getPos().equals(otherControllerPos)) {
IBlockState state = world.getBlockState(otherControllerPos); IBlockState state = world.getBlockState(otherControllerPos);
ItemStack stackToSpawn = ItemBlockController.createStack(new ItemStack(RSBlocks.CONTROLLER, 1, state.getBlock().getMetaFromState(state))); TileController otherController = (TileController) world.getTileEntity(otherControllerPos);
ItemStack stackToSpawn = ItemBlockController.createStack(new ItemStack(RSBlocks.CONTROLLER, 1, state.getBlock().getMetaFromState(state)), otherController.getEnergy().getStored());
world.setBlockToAir(otherControllerPos); world.setBlockToAir(otherControllerPos);

View File

@@ -7,12 +7,12 @@ import com.raoulvdberge.refinedstorage.block.enums.ControllerType;
import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder;
import com.raoulvdberge.refinedstorage.item.itemblock.ItemBlockController; import com.raoulvdberge.refinedstorage.item.itemblock.ItemBlockController;
import com.raoulvdberge.refinedstorage.render.IModelRegistration; import com.raoulvdberge.refinedstorage.render.IModelRegistration;
import com.raoulvdberge.refinedstorage.render.meshdefinition.ItemMeshDefinitionController;
import com.raoulvdberge.refinedstorage.tile.TileController; import com.raoulvdberge.refinedstorage.tile.TileController;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.statemap.StateMap;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@@ -39,25 +39,16 @@ public class BlockController extends BlockNodeProxy {
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerModels(IModelRegistration modelRegistration) { public void registerModels(IModelRegistration modelRegistration) {
modelRegistration.setModelMeshDefinition(this, stack -> { modelRegistration.setModelMeshDefinition(this, new ItemMeshDefinitionController());
ControllerEnergyType energyType = stack.getItemDamage() == ControllerType.CREATIVE.getId() ? ControllerEnergyType.ON : TileController.getEnergyType(ItemBlockController.getEnergyStored(stack), RS.INSTANCE.config.controllerCapacity);
return new ModelResourceLocation(RS.ID + ":controller", "energy_type=" + energyType); modelRegistration.setStateMapper(this, new StateMap.Builder().ignore(TYPE).build());
});
modelRegistration.setStateMapper(this, new StateMapperBase() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
return new ModelResourceLocation(RS.ID + ":controller", "energy_type=" + state.getValue(ENERGY_TYPE));
}
});
} }
@Override @Override
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> items) { public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> items) {
for (int i = 0; i <= 1; i++) { items.add(ItemBlockController.createStack(new ItemStack(this, 1, 0), 0));
items.add(ItemBlockController.createStack(new ItemStack(this, 1, i))); items.add(ItemBlockController.createStack(new ItemStack(this, 1, 0), RS.INSTANCE.config.controllerCapacity));
} items.add(ItemBlockController.createStack(new ItemStack(this, 1, 1), 0));
} }
@Override @Override

View File

@@ -9,6 +9,7 @@ import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -17,6 +18,23 @@ import java.util.List;
public class ItemBlockController extends ItemBlockBase { public class ItemBlockController extends ItemBlockBase {
public ItemBlockController(BlockController block) { public ItemBlockController(BlockController block) {
super(block, true); super(block, true);
setMaxStackSize(1);
}
@Override
public double getDurabilityForDisplay(ItemStack stack) {
return 1D - ((double) getEnergyStored(stack) / (double) RS.INSTANCE.config.controllerCapacity);
}
@Override
public int getRGBDurabilityForDisplay(ItemStack stack) {
return MathHelper.hsvToRGB(Math.max(0.0F, (float) getEnergyStored(stack) / (float) RS.INSTANCE.config.controllerCapacity) / 3.0F, 1.0F, 1.0F);
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
return stack.getMetadata() != ControllerType.CREATIVE.getId();
} }
@Override @Override
@@ -36,17 +54,19 @@ public class ItemBlockController extends ItemBlockBase {
public void onCreated(ItemStack stack, World world, EntityPlayer player) { public void onCreated(ItemStack stack, World world, EntityPlayer player) {
super.onCreated(stack, world, player); super.onCreated(stack, world, player);
createStack(stack); createStack(stack, 0);
} }
public static ItemStack createStack(ItemStack stack) { public static ItemStack createStack(ItemStack stack, int energy) {
NBTTagCompound tag = stack.getTagCompound(); NBTTagCompound tag = stack.getTagCompound();
if (tag == null) { if (tag == null) {
tag = new NBTTagCompound(); tag = new NBTTagCompound();
} }
tag.setInteger(TileController.NBT_ENERGY, stack.getMetadata() == ControllerType.CREATIVE.getId() ? RS.INSTANCE.config.controllerCapacity : 0); tag.setInteger(TileController.NBT_ENERGY, stack.getMetadata() == ControllerType.CREATIVE.getId() ? RS.INSTANCE.config.controllerCapacity : energy);
stack.setTagCompound(tag);
return stack; return stack;
} }

View File

@@ -0,0 +1,19 @@
package com.raoulvdberge.refinedstorage.render.meshdefinition;
import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.block.enums.ControllerEnergyType;
import com.raoulvdberge.refinedstorage.block.enums.ControllerType;
import com.raoulvdberge.refinedstorage.item.itemblock.ItemBlockController;
import com.raoulvdberge.refinedstorage.tile.TileController;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.ItemStack;
public class ItemMeshDefinitionController implements ItemMeshDefinition {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
ControllerEnergyType energyType = stack.getItemDamage() == ControllerType.CREATIVE.getId() ? ControllerEnergyType.ON : TileController.getEnergyType(ItemBlockController.getEnergyStored(stack), RS.INSTANCE.config.controllerCapacity);
return new ModelResourceLocation(RS.ID + ":controller", "energy_type=" + energyType);
}
}