mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-17 02:55:13 +00:00
Improve code readability in binnie.extratrees package
This commit is contained in:
1 parent
adccdd181a
commit
96e4814ae3
225 files changed
+8968
-9306
No files matched your search
@@ -1,87 +1,93 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.extratrees.carpentry;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.IIcon;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.block.BlockMetadata;
|
||||
import binnie.core.block.IMultipassBlock;
|
||||
import binnie.core.block.MultipassBlockRenderer;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
import binnie.extratrees.api.CarpentryManager;
|
||||
import binnie.extratrees.api.IDesign;
|
||||
import binnie.extratrees.api.IDesignSystem;
|
||||
import binnie.extratrees.api.IToolHammer;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import binnie.core.block.MultipassBlockRenderer;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.extratrees.api.CarpentryManager;
|
||||
import java.util.List;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import binnie.extratrees.api.IDesign;
|
||||
import net.minecraft.block.material.Material;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import binnie.extratrees.api.IToolHammer;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import binnie.extratrees.api.IDesignSystem;
|
||||
import binnie.core.block.IMultipassBlock;
|
||||
import binnie.core.block.BlockMetadata;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
public abstract class BlockDesign extends BlockMetadata implements IMultipassBlock
|
||||
{
|
||||
IDesignSystem designSystem;
|
||||
public static final ForgeDirection[] RENDER_DIRECTIONS;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BlockDesign extends BlockMetadata implements IMultipassBlock {
|
||||
public static ForgeDirection[] RENDER_DIRECTIONS = new ForgeDirection[]{
|
||||
ForgeDirection.DOWN,
|
||||
ForgeDirection.UP,
|
||||
ForgeDirection.EAST,
|
||||
ForgeDirection.WEST,
|
||||
ForgeDirection.NORTH,
|
||||
ForgeDirection.SOUTH
|
||||
};
|
||||
|
||||
protected IDesignSystem designSystem;
|
||||
|
||||
public BlockDesign(IDesignSystem system, Material material) {
|
||||
super(material);
|
||||
designSystem = system;
|
||||
}
|
||||
|
||||
public static int getMetadata(int plank1, int plank2, int design) {
|
||||
return plank1 + (plank2 << 9) + (design << 18);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onClick(final PlayerInteractEvent event) {
|
||||
public void onClick(PlayerInteractEvent event) {
|
||||
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
|
||||
return;
|
||||
}
|
||||
final World world = event.entityPlayer.worldObj;
|
||||
final EntityPlayer player = event.entityPlayer;
|
||||
final int x = event.x;
|
||||
final int y = event.y;
|
||||
final int z = event.z;
|
||||
|
||||
World world = event.entityPlayer.worldObj;
|
||||
EntityPlayer player = event.entityPlayer;
|
||||
int x = event.x;
|
||||
int y = event.y;
|
||||
int z = event.z;
|
||||
if (!(world.getBlock(x, y, z) instanceof BlockDesign)) {
|
||||
return;
|
||||
}
|
||||
final BlockDesign blockC = (BlockDesign) world.getBlock(x, y, z);
|
||||
final ItemStack item = player.getHeldItem();
|
||||
if (item == null) {
|
||||
|
||||
BlockDesign blockC = (BlockDesign) world.getBlock(x, y, z);
|
||||
ItemStack item = player.getHeldItem();
|
||||
if (item == null
|
||||
|| !(item.getItem() instanceof IToolHammer)
|
||||
|| !((IToolHammer) item.getItem()).isActive(item)) {
|
||||
return;
|
||||
}
|
||||
if (!(item.getItem() instanceof IToolHammer)) {
|
||||
return;
|
||||
}
|
||||
if (!((IToolHammer) item.getItem()).isActive(item)) {
|
||||
return;
|
||||
}
|
||||
final DesignBlock block = blockC.getCarpentryBlock(world, x, y, z);
|
||||
final TileEntityMetadata tile = (TileEntityMetadata) world.getTileEntity(x, y, z);
|
||||
|
||||
DesignBlock block = blockC.getCarpentryBlock(world, x, y, z);
|
||||
TileEntityMetadata tile = (TileEntityMetadata) world.getTileEntity(x, y, z);
|
||||
block.rotate(event.face, item, player, world, x, y, z);
|
||||
final int meta = block.getBlockMetadata(blockC.getDesignSystem());
|
||||
int meta = block.getBlockMetadata(blockC.getDesignSystem());
|
||||
tile.setTileMetadata(meta, true);
|
||||
}
|
||||
|
||||
public BlockDesign(final IDesignSystem system, final Material material) {
|
||||
super(material);
|
||||
this.designSystem = system;
|
||||
}
|
||||
|
||||
public abstract ItemStack getCreativeStack(final IDesign p0);
|
||||
public abstract ItemStack getCreativeStack(IDesign design);
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs, final List itemList) {
|
||||
for (final IDesign design : CarpentryManager.carpentryInterface.getSortedDesigns()) {
|
||||
itemList.add(this.getCreativeStack(design));
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||
for (IDesign design : CarpentryManager.carpentryInterface.getSortedDesigns()) {
|
||||
list.add(getCreativeStack(design));
|
||||
}
|
||||
}
|
||||
|
||||
public IDesignSystem getDesignSystem() {
|
||||
return this.designSystem;
|
||||
return designSystem;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,86 +96,79 @@ public abstract class BlockDesign extends BlockMetadata implements IMultipassBlo
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockName(final ItemStack itemStack) {
|
||||
final DesignBlock block = ModuleCarpentry.getDesignBlock(this.getDesignSystem(), TileEntityMetadata.getItemDamage(itemStack));
|
||||
return this.getBlockName(block);
|
||||
public String getBlockName(ItemStack stack) {
|
||||
DesignBlock block = ModuleCarpentry.getDesignBlock(getDesignSystem(), TileEntityMetadata.getItemDamage(stack));
|
||||
return getBlockName(block);
|
||||
}
|
||||
|
||||
public abstract String getBlockName(final DesignBlock p0);
|
||||
public abstract String getBlockName(DesignBlock p0);
|
||||
|
||||
public DesignBlock getCarpentryBlock(final IBlockAccess world, final int x, final int y, final int z) {
|
||||
return ModuleCarpentry.getDesignBlock(this.getDesignSystem(), TileEntityMetadata.getTileMetadata(world, x, y, z));
|
||||
public DesignBlock getCarpentryBlock(IBlockAccess world, int x, int y, int z) {
|
||||
return ModuleCarpentry.getDesignBlock(getDesignSystem(), TileEntityMetadata.getTileMetadata(world, x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int colorMultiplier(final IBlockAccess world, final int x, final int y, final int z) {
|
||||
final DesignBlock block = this.getCarpentryBlock(world, x, y, z);
|
||||
public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
|
||||
DesignBlock block = getCarpentryBlock(world, x, y, z);
|
||||
return (MultipassBlockRenderer.getLayer() > 0) ? block.getSecondaryColour() : block.getPrimaryColour();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int colorMultiplier(final int meta) {
|
||||
final DesignBlock block = ModuleCarpentry.getDesignBlock(this.getDesignSystem(), meta);
|
||||
public int colorMultiplier(int meta) {
|
||||
DesignBlock block = ModuleCarpentry.getDesignBlock(getDesignSystem(), meta);
|
||||
return (MultipassBlockRenderer.getLayer() > 0) ? block.getSecondaryColour() : block.getPrimaryColour();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(final int side, final int damage) {
|
||||
final DesignBlock block = ModuleCarpentry.getDesignBlock(this.getDesignSystem(), damage);
|
||||
final IIcon icon = (MultipassBlockRenderer.getLayer() > 0) ? block.getSecondaryIcon(this.getDesignSystem(), BlockDesign.RENDER_DIRECTIONS[side]) : block.getPrimaryIcon(this.getDesignSystem(), BlockDesign.RENDER_DIRECTIONS[side]);
|
||||
return icon;
|
||||
public IIcon getIcon(int side, int damage) {
|
||||
DesignBlock block = ModuleCarpentry.getDesignBlock(getDesignSystem(), damage);
|
||||
if (MultipassBlockRenderer.getLayer() > 0) {
|
||||
return block.getSecondaryIcon(getDesignSystem(), BlockDesign.RENDER_DIRECTIONS[side]);
|
||||
}
|
||||
return block.getPrimaryIcon(getDesignSystem(), BlockDesign.RENDER_DIRECTIONS[side]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBlockTooltip(final ItemStack itemStack, final List tooltip) {
|
||||
final DesignBlock block = ModuleCarpentry.getDesignBlock(this.getDesignSystem(), TileEntityMetadata.getItemDamage(itemStack));
|
||||
public void getBlockTooltip(ItemStack stack, List tooltip) {
|
||||
DesignBlock block = ModuleCarpentry.getDesignBlock(getDesignSystem(), TileEntityMetadata.getItemDamage(stack));
|
||||
if (block.getPrimaryMaterial() != block.getSecondaryMaterial()) {
|
||||
tooltip.add(block.getPrimaryMaterial().getName() + " and " + block.getSecondaryMaterial().getName());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
tooltip.add(block.getPrimaryMaterial().getName());
|
||||
}
|
||||
}
|
||||
|
||||
public int primaryColor(final int damage) {
|
||||
final DesignBlock block = ModuleCarpentry.getDesignBlock(this.getDesignSystem(), damage);
|
||||
public int primaryColor(int damage) {
|
||||
DesignBlock block = ModuleCarpentry.getDesignBlock(getDesignSystem(), damage);
|
||||
return block.getPrimaryColour();
|
||||
}
|
||||
|
||||
public int secondaryColor(final int damage) {
|
||||
final DesignBlock block = ModuleCarpentry.getDesignBlock(this.getDesignSystem(), damage);
|
||||
public int secondaryColor(int damage) {
|
||||
DesignBlock block = ModuleCarpentry.getDesignBlock(getDesignSystem(), damage);
|
||||
return block.getSecondaryColour();
|
||||
}
|
||||
|
||||
public ItemStack getItemStack(final int plank1, final int plank2, final int design) {
|
||||
public ItemStack getItemStack(int plank1, int plank2, int design) {
|
||||
return TileEntityMetadata.getItemStack(this, getMetadata(plank1, plank2, design));
|
||||
}
|
||||
|
||||
public static int getMetadata(final int plank1, final int plank2, final int design) {
|
||||
return plank1 + (plank2 << 9) + (design << 18);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(final IIconRegister register) {
|
||||
for (final IDesignSystem system : DesignerManager.instance.getDesignSystems()) {
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
for (IDesignSystem system : DesignerManager.instance.getDesignSystems()) {
|
||||
system.registerIcons(register);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDroppedMeta(final int blockMeta, final int tileMeta) {
|
||||
final DesignBlock block = ModuleCarpentry.getDesignBlock(this.getDesignSystem(), tileMeta);
|
||||
return block.getItemMetadata(this.getDesignSystem());
|
||||
public int getDroppedMeta(int blockMeta, int tileMeta) {
|
||||
DesignBlock block = ModuleCarpentry.getDesignBlock(getDesignSystem(), tileMeta);
|
||||
return block.getItemMetadata(getDesignSystem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfPasses() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
static {
|
||||
RENDER_DIRECTIONS = new ForgeDirection[] { ForgeDirection.DOWN, ForgeDirection.UP, ForgeDirection.EAST, ForgeDirection.WEST, ForgeDirection.NORTH, ForgeDirection.SOUTH };
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user