Skip to content

Commit

Permalink
Rename GUIsID to GUIIDs
Browse files Browse the repository at this point in the history
Also add in meta sensitivity to getFinalCopperMeta
  • Loading branch information
Roadhog360 committed Sep 17, 2023
1 parent d283f2c commit 6d3c7e7
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 44 deletions.
4 changes: 2 additions & 2 deletions src/main/java/ganymedes01/etfuturum/blocks/BlockBarrel.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import cpw.mods.fml.relauncher.SideOnly;
import ganymedes01.etfuturum.EtFuturum;
import ganymedes01.etfuturum.core.utils.Utils;
import ganymedes01.etfuturum.lib.GUIsID;
import ganymedes01.etfuturum.lib.GUIIDs;
import ganymedes01.etfuturum.lib.RenderIDs;
import ganymedes01.etfuturum.tileentities.TileEntityBarrel;
import net.minecraft.block.Block;
Expand Down Expand Up @@ -80,7 +80,7 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p
if (world.isRemote) {
return true;
}
player.openGui(EtFuturum.instance, GUIsID.BARREL, world, x, y, z);
player.openGui(EtFuturum.instance, GUIIDs.BARREL, world, x, y, z);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import ganymedes01.etfuturum.client.InterpolatedIcon;
import ganymedes01.etfuturum.configuration.configs.ConfigSounds;
import ganymedes01.etfuturum.core.utils.Utils;
import ganymedes01.etfuturum.lib.GUIsID;
import ganymedes01.etfuturum.lib.GUIIDs;
import ganymedes01.etfuturum.lib.Reference;
import ganymedes01.etfuturum.tileentities.TileEntityBlastFurnace;
import net.minecraft.block.Block;
Expand Down Expand Up @@ -172,7 +172,7 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p
if (world.isRemote) {
return true;
}
player.openGui(EtFuturum.instance, GUIsID.BLAST_FURNACE, world, x, y, z);
player.openGui(EtFuturum.instance, GUIIDs.BLAST_FURNACE, world, x, y, z);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

import java.util.Random;
Expand Down Expand Up @@ -47,7 +48,7 @@ public void registerBlockIcons(IIconRegister reg) {
}

@Override
public int getFinalCopperMeta(int copperMeta, int worldMeta) {
public int getFinalCopperMeta(IBlockAccess world, int x, int y, int z, int copperMeta, int worldMeta) {
return (copperMeta - (copperMeta > 11 ? 8 : 4)) + (worldMeta > 7 ? 8 : 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ganymedes01.etfuturum.ModBlocks;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

import java.util.Random;
Expand Down Expand Up @@ -88,7 +89,7 @@ public Block getCopperBlockFromMeta(int i) {
}

@Override
public int getFinalCopperMeta(int meta, int worldMeta) {
public int getFinalCopperMeta(IBlockAccess world, int x, int y, int z, int meta, int worldMeta) {
return worldMeta;
}
}
4 changes: 2 additions & 2 deletions src/main/java/ganymedes01/etfuturum/blocks/BlockNewAnvil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import ganymedes01.etfuturum.EtFuturum;
import ganymedes01.etfuturum.ModBlocks;
import ganymedes01.etfuturum.configuration.configs.ConfigWorld;
import ganymedes01.etfuturum.lib.GUIsID;
import ganymedes01.etfuturum.lib.GUIIDs;
import net.minecraft.block.BlockAnvil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
Expand Down Expand Up @@ -43,7 +43,7 @@ public Item getItem(World world, int x, int y, int z) {
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if (world.isRemote)
return true;
player.openGui(EtFuturum.instance, GUIsID.ANVIL, world, x, y, z);
player.openGui(EtFuturum.instance, GUIIDs.ANVIL, world, x, y, z);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import ganymedes01.etfuturum.EtFuturum;
import ganymedes01.etfuturum.ModBlocks;
import ganymedes01.etfuturum.configuration.configs.ConfigWorld;
import ganymedes01.etfuturum.lib.GUIsID;
import ganymedes01.etfuturum.lib.GUIIDs;
import ganymedes01.etfuturum.tileentities.TileEntityNewBrewingStand;
import net.minecraft.block.BlockBrewingStand;
import net.minecraft.entity.player.EntityPlayer;
Expand Down Expand Up @@ -38,7 +38,7 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p

TileEntityBrewingStand tile = (TileEntityBrewingStand) world.getTileEntity(x, y, z);
if (tile != null)
player.openGui(EtFuturum.instance, GUIsID.BREWING_STAND, world, x, y, z);
player.openGui(EtFuturum.instance, GUIIDs.BREWING_STAND, world, x, y, z);

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import ganymedes01.etfuturum.EtFuturum;
import ganymedes01.etfuturum.ModBlocks;
import ganymedes01.etfuturum.configuration.configs.ConfigWorld;
import ganymedes01.etfuturum.lib.GUIsID;
import ganymedes01.etfuturum.lib.GUIIDs;
import net.minecraft.block.BlockEnchantmentTable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
Expand Down Expand Up @@ -43,7 +43,7 @@ public Item getItem(World world, int x, int y, int z) {
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if (world.isRemote)
return true;
player.openGui(EtFuturum.instance, GUIsID.ENCHANTING_TABLE, world, x, y, z);
player.openGui(EtFuturum.instance, GUIIDs.ENCHANTING_TABLE, world, x, y, z);
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import ganymedes01.etfuturum.configuration.configs.ConfigModCompat;
import ganymedes01.etfuturum.core.utils.Utils;
import ganymedes01.etfuturum.items.BaseSubtypesItem;
import ganymedes01.etfuturum.lib.GUIsID;
import ganymedes01.etfuturum.lib.GUIIDs;
import ganymedes01.etfuturum.tileentities.TileEntityShulkerBox;
import ganymedes01.etfuturum.tileentities.TileEntityShulkerBox.ShulkerBoxType;
import net.minecraft.block.Block;
Expand Down Expand Up @@ -158,7 +158,7 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p
}

if (flag) {
player.openGui(EtFuturum.instance, GUIsID.SHULKER_BOX, world, x, y, z);
player.openGui(EtFuturum.instance, GUIIDs.SHULKER_BOX, world, x, y, z);
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import cpw.mods.fml.relauncher.SideOnly;
import ganymedes01.etfuturum.EtFuturum;
import ganymedes01.etfuturum.core.utils.Utils;
import ganymedes01.etfuturum.lib.GUIsID;
import ganymedes01.etfuturum.lib.GUIIDs;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
Expand Down Expand Up @@ -48,7 +48,7 @@ public void registerBlockIcons(IIconRegister p_149651_1_) {
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float subX, float subY, float subZ) {
if (!world.isRemote)
player.openGui(EtFuturum.instance, GUIsID.SMITHING_TABLE, world, x, y, z);
player.openGui(EtFuturum.instance, GUIIDs.SMITHING_TABLE, world, x, y, z);
return true;
}
}
4 changes: 2 additions & 2 deletions src/main/java/ganymedes01/etfuturum/blocks/BlockSmoker.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import ganymedes01.etfuturum.ModBlocks;
import ganymedes01.etfuturum.configuration.configs.ConfigSounds;
import ganymedes01.etfuturum.core.utils.Utils;
import ganymedes01.etfuturum.lib.GUIsID;
import ganymedes01.etfuturum.lib.GUIIDs;
import ganymedes01.etfuturum.lib.Reference;
import ganymedes01.etfuturum.tileentities.TileEntitySmoker;
import net.minecraft.block.Block;
Expand Down Expand Up @@ -155,7 +155,7 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p
if (world.isRemote) {
return true;
}
player.openGui(EtFuturum.instance, GUIsID.SMOKER, world, x, y, z);
player.openGui(EtFuturum.instance, GUIIDs.SMOKER, world, x, y, z);
return true;
}

Expand Down
19 changes: 14 additions & 5 deletions src/main/java/ganymedes01/etfuturum/blocks/IDegradable.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ default int getCopperMeta(IBlockAccess world, int x, int y, int z, int meta) {
return getCopperMeta(meta);
}

/**
* Deprecated, use getFinalCopperMeta(IBlockAccess world, int x, int y, int z, int meta, int worldMeta)
*/
@Deprecated
default int getFinalCopperMeta(int meta, int worldMeta) {
return getCopperMeta(meta);
}


/**
* A getCopperMeta copy that takes the actual meta value of the block into account.
* Used by slabs to wrap the meta data from 0-7 or 8-15.
Expand All @@ -65,8 +74,8 @@ default int getCopperMeta(IBlockAccess world, int x, int y, int z, int meta) {
* @param worldMeta World meta (Is always the meta value from before the copper changed and is the actual block meta, not the copper ID)
* @return A copper value from getCopperMeta.
*/
default int getFinalCopperMeta(int meta, int worldMeta) {
return getCopperMeta(meta);
default int getFinalCopperMeta(IBlockAccess world, int x, int y, int z, int meta, int worldMeta) {
return getCopperMeta(world, x, y, z, meta);
}


Expand Down Expand Up @@ -126,7 +135,7 @@ default void tryDegrade(World world, int x, int y, int z, Random random) {
float f = (float) (k + 1) / (float) (k + j + 1);
float g = f * f * (i % 4 == 0 ? 0.75F : 1F);
if (random.nextFloat() < g) {
setCopperBlock(getCopperBlockFromMeta(i + 1), getFinalCopperMeta(i + 1, world.getBlockMetadata(x, y, z)), world, x, y, z);
setCopperBlock(getCopperBlockFromMeta(i + 1), getFinalCopperMeta(world, x, y, z, i + 1, world.getBlockMetadata(x, y, z)), world, x, y, z);
}
}
}
Expand Down Expand Up @@ -180,11 +189,11 @@ default boolean tryWaxOnWaxOff(World world, int x, int y, int z, EntityPlayer en
if (flag && !flag2) {
waxMeta = meta > 7 ? meta % 8 : (meta % 8 + 8);
block = getCopperBlockFromMeta(waxMeta);
setCopperBlock(block, getFinalCopperMeta(waxMeta, world.getBlockMetadata(x, y, z)), world, x, y, z);
setCopperBlock(block, getFinalCopperMeta(world, x, y, z, waxMeta, world.getBlockMetadata(x, y, z)), world, x, y, z);
spawnParticles(world, x, y, z, meta < 8 ? 0 : 1);
} else if (!flag && flag2) {
block = getCopperBlockFromMeta(meta - 1);
setCopperBlock(block, getFinalCopperMeta(meta - 1, world.getBlockMetadata(x, y, z)), world, x, y, z);
setCopperBlock(block, getFinalCopperMeta(world, x, y, z, meta - 1, world.getBlockMetadata(x, y, z)), world, x, y, z);
spawnParticles(world, x, y, z, 2);
}
}
Expand Down
40 changes: 20 additions & 20 deletions src/main/java/ganymedes01/etfuturum/core/proxy/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import ganymedes01.etfuturum.core.utils.Utils;
import ganymedes01.etfuturum.entities.*;
import ganymedes01.etfuturum.inventory.*;
import ganymedes01.etfuturum.lib.GUIsID;
import ganymedes01.etfuturum.lib.GUIIDs;
import ganymedes01.etfuturum.spectator.SpectatorMode;
import ganymedes01.etfuturum.tileentities.*;
import net.minecraft.client.gui.inventory.GuiChest;
Expand Down Expand Up @@ -176,27 +176,24 @@ public void registerEntities() {
EntityRegistry.addSpawn(EntityMagmaCube.class, 2, 4, 4, EnumCreatureType.monster, BiomeGenBase.hell);
}

public void registerRenderers() {
}

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
switch (ID) {
case GUIsID.ENCHANTING_TABLE:
case GUIIDs.ENCHANTING_TABLE:
return new ContainerEnchantment(player.inventory, world, x, y, z);
case GUIsID.ANVIL:
case GUIIDs.ANVIL:
return new ContainerAnvil(player, world, x, y, z);
case GUIsID.BREWING_STAND:
case GUIIDs.BREWING_STAND:
return new ContainerNewBrewingStand(player.inventory, (TileEntityNewBrewingStand) world.getTileEntity(x, y, z));
case GUIsID.BARREL:
case GUIIDs.BARREL:
return new ContainerChest(player.inventory, (TileEntityBarrel) world.getTileEntity(x, y, z));
case GUIsID.SMOKER:
case GUIIDs.SMOKER:
return new ContainerSmoker(player.inventory, (TileEntitySmoker) world.getTileEntity(x, y, z));
case GUIsID.BLAST_FURNACE:
case GUIIDs.BLAST_FURNACE:
return new ContainerBlastFurnace(player.inventory, (TileEntityBlastFurnace) world.getTileEntity(x, y, z));
case GUIsID.SHULKER_BOX:
case GUIIDs.SHULKER_BOX:
return new ContainerChestGeneric(player.inventory, (TileEntityShulkerBox) world.getTileEntity(x, y, z), ((TileEntityShulkerBox) world.getTileEntity(x, y, z)).getRowSize(), ((TileEntityShulkerBox) world.getTileEntity(x, y, z)).getSizeInventory() != 27);
case GUIsID.SMITHING_TABLE:
case GUIIDs.SMITHING_TABLE:
return new ContainerSmithingTable(player.inventory, world);
default:
return null;
Expand All @@ -206,24 +203,27 @@ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
switch (ID) {
case GUIsID.ENCHANTING_TABLE:
case GUIIDs.ENCHANTING_TABLE:
return new GuiEnchantment(player.inventory, world, null);
case GUIsID.ANVIL:
case GUIIDs.ANVIL:
return new GuiAnvil(player, world, x, y, z);
case GUIsID.BREWING_STAND:
case GUIIDs.BREWING_STAND:
return new GuiNewBrewingStand(player.inventory, (TileEntityNewBrewingStand) world.getTileEntity(x, y, z));
case GUIsID.BARREL:
case GUIIDs.BARREL:
return new GuiChest(player.inventory, (TileEntityBarrel) world.getTileEntity(x, y, z));
case GUIsID.SMOKER:
case GUIIDs.SMOKER:
return new GuiSmoker(player.inventory, (TileEntitySmoker) world.getTileEntity(x, y, z));
case GUIsID.BLAST_FURNACE:
case GUIIDs.BLAST_FURNACE:
return new GuiBlastFurnace(player.inventory, (TileEntityBlastFurnace) world.getTileEntity(x, y, z));
case GUIsID.SHULKER_BOX:
case GUIIDs.SHULKER_BOX:
return new GuiShulkerBox(player.inventory, (TileEntityShulkerBox) world.getTileEntity(x, y, z));
case GUIsID.SMITHING_TABLE:
case GUIIDs.SMITHING_TABLE:
return new GuiSmithingTable(new ContainerSmithingTable(player.inventory, world));
default:
return null;
}
}

public void registerRenderers() {
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ganymedes01.etfuturum.lib;

public class GUIsID {
public class GUIIDs {

public static final int ENCHANTING_TABLE = 0;
public static final int ANVIL = 1;
Expand Down

0 comments on commit 6d3c7e7

Please sign in to comment.