GUI fixes

This commit is contained in:
drcrazy 2019-02-22 11:51:55 +03:00
parent f78b16293f
commit a003656419
15 changed files with 59 additions and 110 deletions

View file

@ -25,10 +25,14 @@
package techreborn.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFire;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.Tag;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@ -40,6 +44,7 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.IEnergyStorage;
@ -67,70 +72,23 @@ public class BlockRubberLog extends Block {
public static BooleanProperty HAS_SAP = BooleanProperty.create("hassap");
public BlockRubberLog() {
super(Material.WOOD);
this.setHardness(2.0F);
super(Block.Properties.create(Material.WOOD).hardnessAndResistance(2f).sound(SoundType.WOOD).needsRandomTick());
this.setDefaultState(
this.getDefaultState().with(SAP_SIDE, EnumFacing.NORTH).with(HAS_SAP, false));
this.setTickRandomly(true);
this.setSoundType(SoundType.WOOD);
Blocks.FIRE.setFireInfo(this, 5, 5);
((BlockFire) Blocks.FIRE).setFireInfo(this, 5, 5);
RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this));
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, SAP_SIDE, HAS_SAP);
protected void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder) {
SAP_SIDE = DirectionProperty.create("sapside", EnumFacing.Plane.HORIZONTAL);
HAS_SAP = BooleanProperty.create("hassap");
builder.add(SAP_SIDE, HAS_SAP);
}
@Override
public IBlockState getStateFromMeta(int meta) {
boolean hasSap = false;
int tempMeta = meta;
if (meta > 3) {
hasSap = true;
tempMeta -= 3;
}
EnumFacing facing = EnumFacing.byHorizontalIndex(tempMeta);
return this.getDefaultState().with(SAP_SIDE, facing).with(HAS_SAP, hasSap);
}
@Override
public int getMetaFromState(IBlockState state) {
int tempMeta = 0;
EnumFacing facing = state.getValue(SAP_SIDE);
switch (facing) {
case SOUTH:
tempMeta = 0;
break;
case WEST:
tempMeta = 1;
break;
case NORTH:
tempMeta = 2;
break;
case EAST:
tempMeta = 3;
break;
case UP:
tempMeta = 0;
break;
case DOWN:
tempMeta = 0;
}
if (state.getValue(HAS_SAP)) {
tempMeta += 4;
}
return tempMeta;
}
@Override
public boolean canSustainLeaves(IBlockState state, IBlockAccess world, BlockPos pos) {
return true;
}
@Override
public boolean isWood(net.minecraft.world.IBlockAccess world, BlockPos pos) {
return true;
public boolean isIn(Tag<Block> tagIn) {
return tagIn == BlockTags.LOGS;
}
@Override
@ -199,15 +157,10 @@ public class BlockRubberLog extends Block {
return false;
}
@Override
public int damageDropped(IBlockState state) {
return 0;
}
@Override
public void getDrops(IBlockState state, NonNullList<ItemStack> drops, World world, BlockPos pos, int fortune) {
drops.add(new ItemStack(this));
if (state.getValue(HAS_SAP)) {
if (state.get(HAS_SAP)) {
if (new Random().nextInt(4) == 0) {
drops.add(TRContent.Parts.SAP.getStack());
}

View file

@ -48,7 +48,7 @@ public class GuiAlloyFurnace extends GuiContainer {
@Override
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
this.drawDefaultBackground();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(GuiAlloyFurnace.texture);
final int k = (this.width - this.xSize) / 2;
final int l = (this.height - this.ySize) / 2;

View file

@ -27,7 +27,6 @@ package techreborn.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
@ -61,21 +60,16 @@ public class GuiAutoCrafting extends GuiBase {
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
RenderHelper.enableGUIStandardItemLighting();
RenderItem itemRenderer = Minecraft.getInstance().getRenderItem();
itemRenderer.renderItemAndEffectIntoGUI(stack, x, y);
itemRender.renderItemAndEffectIntoGUI(stack, x, y);
GlStateManager.disableLighting();
GlStateManager.pushMatrix();
GlStateManager.disableDepth();
GlStateManager.color(1, 1, 1, 1F / 3F);
GlStateManager.disableDepthTest();
GlStateManager.color4f(1, 1, 1, 1F / 3F);
drawRect(x - 4, y- 4, x + 20, y + 20, -2139062144);
GlStateManager.enableDepth();
GlStateManager.color(1F, 1F, 1F, 1F);
GlStateManager.enableDepthTest();
GlStateManager.color4f(1F, 1F, 1F, 1F);
GlStateManager.enableBlend();
GlStateManager.popMatrix();
}
}

View file

@ -55,7 +55,7 @@ public class GuiBatbox extends GuiBase {
if(GuiBase.slotConfigType == SlotConfigType.NONE){
GlStateManager.pushMatrix();
GlStateManager.scale(0.6, 0.6, 5);
GlStateManager.scaled(0.6, 0.6, 5);
drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) tile.getEnergy()) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) tile.getMaxPower()) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer);
GlStateManager.popMatrix();
}

View file

@ -64,7 +64,7 @@ public class GuiBlastFurnace extends GuiBase {
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
this.hasMultiBlock = this.tile.getCachedHeat() != 0;
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
final GuiBase.Layer layer = Layer.BACKGROUND;
drawSlot(8, 72, layer);

View file

@ -70,7 +70,7 @@ public class GuiChunkLoader extends GuiContainer {
@Override
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
this.drawDefaultBackground();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(GuiChunkLoader.texture);
final int k = (this.width - this.xSize) / 2;
final int l = (this.height - this.ySize) / 2;

View file

@ -24,7 +24,6 @@
package techreborn.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
@ -45,8 +44,8 @@ public class GuiDestructoPack extends GuiContainer {
@Override
protected void drawGuiContainerBackgroundLayer(float arg0, int arg1, int arg2) {
this.drawDefaultBackground();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getInstance().renderEngine.bindTexture(texture);
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 176, 166);
}

View file

@ -61,7 +61,7 @@ public class GuiDistillationTower extends GuiBase {
protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
final GuiBase.Layer layer = Layer.BACKGROUND;
// Battery slot
drawSlot(8, 72, layer);

View file

@ -55,7 +55,7 @@ public class GuiIDSU extends GuiBase {
final Layer layer = Layer.FOREGROUND;
GlStateManager.pushMatrix();
GlStateManager.scale(0.6, 0.6, 1);
GlStateManager.scaled(0.6, 0.6, 1);
drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) idsu.getEnergy()) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) idsu.getMaxPower()) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer);
GlStateManager.popMatrix();

View file

@ -61,7 +61,7 @@ public class GuiImplosionCompressor extends GuiBase {
protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
final GuiBase.Layer layer = Layer.BACKGROUND;
drawSlot(8, 72, layer);

View file

@ -50,7 +50,7 @@ public class GuiIronFurnace extends GuiBase {
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
drawDefaultBackground();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
builder.drawSlotTab(this, guiLeft - 24, guiTop + 6, new ItemStack(TRContent.WRENCH));
mc.getTextureManager().bindTexture(GuiIronFurnace.texture);
final int k = (this.width - xSize) / 2;

View file

@ -55,7 +55,7 @@ public class GuiLESU extends GuiBase {
final Layer layer = Layer.FOREGROUND;
GlStateManager.pushMatrix();
GlStateManager.scale(0.6, 0.6, 1);
GlStateManager.scaled(0.6, 0.6, 1);
drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) tile.getEnergy()) + "/"
+ PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) tile.getMaxPower()) + " "
+ PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer);

View file

@ -56,7 +56,7 @@ public class GuiMFE extends GuiBase {
if(GuiBase.slotConfigType == SlotConfigType.NONE){
GlStateManager.pushMatrix();
GlStateManager.scale(0.6, 0.6, 1);
GlStateManager.scaled(0.6, 0.6, 1);
drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) mfe.getEnergy()) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) mfe.getMaxPower()) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer);
GlStateManager.popMatrix();
}

View file

@ -55,7 +55,7 @@ public class GuiMFSU extends GuiBase {
final Layer layer = Layer.FOREGROUND;
GlStateManager.pushMatrix();
GlStateManager.scale(0.6, 0.6, 1);
GlStateManager.scaled(0.6, 0.6, 1);
drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) mfsu.getEnergy()) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) mfsu.getMaxPower()) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer);
GlStateManager.popMatrix();

View file

@ -24,10 +24,13 @@
package techreborn.events;
import org.lwjgl.glfw.GLFW;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.InputMappings;
import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@ -60,41 +63,41 @@ public class StackToolTipEvent {
((IListInfoProvider) item).addInfo(event.getToolTip(), false, false);
} else if (event.getItemStack().getItem() instanceof IEnergyItemInfo) {
IEnergyStorage capEnergy = new ForgePowerItemManager(event.getItemStack());
event.getToolTip().add(1, new TextComponentString(
TextFormatting.GOLD + PowerSystem.getLocaliszedPowerFormattedNoSuffix(capEnergy.getEnergyStored() / RebornCoreConfig.euPerFU)
+ "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix(capEnergy.getMaxEnergyStored() / RebornCoreConfig.euPerFU)
+ " " + PowerSystem.getDisplayPower().abbreviation));
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
TextComponentString line1 = new TextComponentString(PowerSystem
.getLocaliszedPowerFormattedNoSuffix(capEnergy.getEnergyStored() / RebornCoreConfig.euPerFU));
line1.appendText("/");
line1.appendText(PowerSystem
.getLocaliszedPowerFormattedNoSuffix(capEnergy.getMaxEnergyStored() / RebornCoreConfig.euPerFU));
line1.appendText(" ");
line1.appendText(PowerSystem.getDisplayPower().abbreviation);
line1.applyTextStyle(TextFormatting.GOLD);
event.getToolTip().add(1, line1);
if (InputMappings.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)
|| InputMappings.isKeyDown(GLFW.GLFW_KEY_RIGHT_SHIFT)) {
int percentage = percentage(capEnergy.getMaxEnergyStored(), capEnergy.getEnergyStored());
TextFormatting color;
if (percentage <= 10) {
color = TextFormatting.RED;
} else if (percentage >= 75) {
color = TextFormatting.GREEN;
} else {
color = TextFormatting.YELLOW;
}
event.getToolTip().add(2, new TextComponentString(color + "" + percentage + "%" + TextFormatting.GRAY + " Charged"));
TextFormatting color = StringUtils.getPercentageColour(percentage);
event.getToolTip().add(2,
new TextComponentString(color + "" + percentage + "%" + TextFormatting.GRAY + " Charged"));
// TODO: show both input and output rates
event.getToolTip().add(3, new TextComponentString(
TextFormatting.GRAY + "I/O Rate: "
event.getToolTip().add(3, new TextComponentString(TextFormatting.GRAY + "I/O Rate: "
+ TextFormatting.GOLD
+ PowerSystem.getLocaliszedPowerFormatted((int) ((IEnergyItemInfo) item).getMaxInput())));
}
}
else {
} else {
try {
Block block = Block.getBlockFromItem(item);
if (block != null && (block instanceof BlockContainer || block instanceof ITileEntityProvider)
&& block.getRegistryName().getNamespace().contains("techreborn")) {
TileEntity tile = block.createTileEntity(Minecraft.getInstance().world,
block.getStateFromMeta(event.getItemStack().getItemDamage()));
&& block.getRegistryName().getNamespace().contains("techreborn")) {
TileEntity tile = block.createTileEntity(block.getDefaultState(), Minecraft.getInstance().world);
boolean hasData = false;
if(event.getItemStack().hasTag() && event.getItemStack().getTag().hasKey("tile_data")){
NBTTagCompound tileData = event.getItemStack().getTag().getCompoundTag("tile_data");
if (event.getItemStack().hasTag() && event.getItemStack().getTag().hasKey("tile_data")) {
NBTTagCompound tileData = event.getItemStack().getTag().getCompound("tile_data");
tile.read(tileData);
hasData = true;
event.getToolTip().add(new TextComponentString(TextFormatting.DARK_GREEN + "Block data contained"));
event.getToolTip()
.add(new TextComponentString("Block data contained").applyTextStyle(TextFormatting.DARK_GREEN));
}
if (tile instanceof IListInfoProvider) {
((IListInfoProvider) tile).addInfo(event.getToolTip(), false, hasData);