mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-16 18:54:54 +00:00
Improve code readability in binnie.genetics package
Drop unused (empty) method MachinePackage#register() from all classes
This commit is contained in:
1 parent
856f08b752
commit
730043ba9c
112 files changed
+4354
-4697
No files matched your search
@@ -1,38 +1,33 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import java.util.List;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extrabees.ExtraBees;
|
||||
import binnie.botany.Botany;
|
||||
import net.minecraft.item.Item;
|
||||
import java.util.ArrayList;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import binnie.core.BinnieCore;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.IMachineType;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.MachinePackage;
|
||||
import binnie.core.machines.component.IInteraction;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import net.minecraft.block.Block;
|
||||
import binnie.extrabees.ExtraBees;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.core.machines.MachinePackage;
|
||||
import binnie.core.machines.IMachineType;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public enum LaboratoryMachine implements IMachineType
|
||||
{
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public enum LaboratoryMachine implements IMachineType {
|
||||
LabMachine(PackageLabMachine.class),
|
||||
Analyser(Analyser.PackageAnalyser.class),
|
||||
Incubator(Incubator.PackageIncubator.class),
|
||||
@@ -41,13 +36,13 @@ public enum LaboratoryMachine implements IMachineType
|
||||
|
||||
Class<? extends MachinePackage> clss;
|
||||
|
||||
private LaboratoryMachine(final Class<? extends MachinePackage> clss) {
|
||||
LaboratoryMachine(Class<? extends MachinePackage> clss) {
|
||||
this.clss = clss;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends MachinePackage> getPackageClass() {
|
||||
return this.clss;
|
||||
return clss;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,104 +50,113 @@ public enum LaboratoryMachine implements IMachineType
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack get(final int i) {
|
||||
return new ItemStack(Genetics.packageLabMachine.getBlock(), i, this.ordinal());
|
||||
public ItemStack get(int i) {
|
||||
return new ItemStack(Genetics.packageLabMachine.getBlock(), i, ordinal());
|
||||
}
|
||||
|
||||
public static class PackageLabMachine extends GeneticMachine.PackageGeneticBase
|
||||
{
|
||||
public static class PackageLabMachine extends GeneticMachine.PackageGeneticBase {
|
||||
public PackageLabMachine() {
|
||||
super("labMachine", GeneticsTexture.LabMachine, 16777215, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGUIHolder(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderMachine(final Machine machine, final double x, final double y, final double z, final float partialTick, final RenderBlocks renderer) {
|
||||
MachineRendererLab.instance.renderMachine(machine, this.colour, this.renderTexture, x, y, z, partialTick);
|
||||
public void renderMachine(Machine machine, double x, double y, double z, float partialTick, RenderBlocks renderer) {
|
||||
MachineRendererLab.instance.renderMachine(machine, colour, renderTexture, x, y, z, partialTick);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentGUIHolder extends MachineComponent implements INetwork.TilePacketSync, IInteraction.RightClick
|
||||
{
|
||||
public static class ComponentGUIHolder extends MachineComponent implements INetwork.TilePacketSync, IInteraction.RightClick {
|
||||
private ItemStack stack;
|
||||
|
||||
public ComponentGUIHolder(final IMachine machine) {
|
||||
public ComponentGUIHolder(IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
public ItemStack getStack() {
|
||||
return this.stack;
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbttagcompound) {
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
if (nbttagcompound == null) {
|
||||
return;
|
||||
}
|
||||
this.stack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("Item"));
|
||||
stack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("Item"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbttagcompound) {
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
if (this.stack != null) {
|
||||
this.stack.writeToNBT(nbt);
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(nbt);
|
||||
}
|
||||
nbttagcompound.setTag("Item", nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(final NBTTagCompound nbt) {
|
||||
this.writeToNBT(nbt);
|
||||
public void syncToNBT(NBTTagCompound nbt) {
|
||||
writeToNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(final NBTTagCompound nbt) {
|
||||
this.readFromNBT(nbt);
|
||||
public void syncFromNBT(NBTTagCompound nbt) {
|
||||
readFromNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestruction() {
|
||||
super.onDestruction();
|
||||
if (this.stack != null) {
|
||||
final float f = this.getMachine().getWorld().rand.nextFloat() * 0.8f + 0.1f;
|
||||
final float f2 = this.getMachine().getWorld().rand.nextFloat() * 0.8f + 0.1f;
|
||||
final float f3 = this.getMachine().getWorld().rand.nextFloat() * 0.8f + 0.1f;
|
||||
if (this.stack.stackSize == 0) {
|
||||
this.stack.stackSize = 1;
|
||||
}
|
||||
final EntityItem entityitem = new EntityItem(this.getMachine().getWorld(), this.getMachine().getTileEntity().xCoord + f, this.getMachine().getTileEntity().yCoord + f2, this.getMachine().getTileEntity().zCoord + f3, this.stack.copy());
|
||||
final float accel = 0.05f;
|
||||
entityitem.motionX = (float) this.getMachine().getWorld().rand.nextGaussian() * accel;
|
||||
entityitem.motionY = (float) this.getMachine().getWorld().rand.nextGaussian() * accel + 0.2f;
|
||||
entityitem.motionZ = (float) this.getMachine().getWorld().rand.nextGaussian() * accel;
|
||||
this.getMachine().getWorld().spawnEntityInWorld(entityitem);
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IMachine machine = getMachine();
|
||||
TileEntity tile = machine.getTileEntity();
|
||||
World world = machine.getWorld();
|
||||
Random rand = world.rand;
|
||||
float xOffset = rand.nextFloat() * 0.8f + 0.1f;
|
||||
float yOffset = rand.nextFloat() * 0.8f + 0.1f;
|
||||
float zOffset = rand.nextFloat() * 0.8f + 0.1f;
|
||||
if (stack.stackSize == 0) {
|
||||
stack.stackSize = 1;
|
||||
}
|
||||
|
||||
EntityItem entityitem = new EntityItem(world, tile.xCoord + xOffset, tile.yCoord + yOffset, tile.zCoord + zOffset, stack.copy());
|
||||
float accel = 0.05f;
|
||||
entityitem.motionX = (float) rand.nextGaussian() * accel;
|
||||
entityitem.motionY = (float) rand.nextGaussian() * accel + 0.2f;
|
||||
entityitem.motionZ = (float) rand.nextGaussian() * accel;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRightClick(final World world, final EntityPlayer player, final int x, final int y, final int z) {
|
||||
public void onRightClick(World world, EntityPlayer player, int x, int y, int z) {
|
||||
if (BinnieCore.proxy.isSimulating(world) && player.getHeldItem() != null) {
|
||||
if (this.stack != null && player.getHeldItem().getItem() instanceof IToolWrench) {
|
||||
final float f = 0.7f;
|
||||
final double d0 = world.rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
final double d2 = world.rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
final double d3 = world.rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
final EntityItem entityitem = new EntityItem(world, x + d0, y + d2, z + d3, this.stack);
|
||||
if (stack != null && player.getHeldItem().getItem() instanceof IToolWrench) {
|
||||
Random rand = world.rand;
|
||||
float f = 0.7f;
|
||||
double fOffset = (1.0f - f) * 0.5;
|
||||
double xOffset = rand.nextFloat() * f + fOffset;
|
||||
double yOffset = rand.nextFloat() * f + fOffset;
|
||||
double zOffset = rand.nextFloat() * f + fOffset;
|
||||
|
||||
EntityItem entityitem = new EntityItem(world, x + xOffset, y + yOffset, z + zOffset, stack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
this.stack = null;
|
||||
stack = null;
|
||||
((IToolWrench) player.getHeldItem().getItem()).wrenchUsed(player, x, y, z);
|
||||
this.getUtil().refreshBlock();
|
||||
getUtil().refreshBlock();
|
||||
return;
|
||||
}
|
||||
final List<Item> validSelections = new ArrayList<Item>();
|
||||
|
||||
List<Item> validSelections = new ArrayList<>();
|
||||
if (BinnieCore.isBotanyActive()) {
|
||||
validSelections.add(Botany.database);
|
||||
}
|
||||
@@ -165,24 +169,28 @@ public enum LaboratoryMachine implements IMachineType
|
||||
if (BinnieCore.isLepidopteryActive()) {
|
||||
validSelections.add(ExtraTrees.itemDictionaryLepi);
|
||||
}
|
||||
|
||||
validSelections.add(Genetics.database);
|
||||
validSelections.add(Genetics.analyst);
|
||||
validSelections.add(Genetics.registry);
|
||||
validSelections.add(Genetics.masterRegistry);
|
||||
validSelections.add(BinnieCore.genesis);
|
||||
if (this.stack == null && validSelections.contains(player.getHeldItem().getItem())) {
|
||||
this.stack = player.getHeldItem().copy();
|
||||
final ItemStack heldItem = player.getHeldItem();
|
||||
--heldItem.stackSize;
|
||||
|
||||
if (stack == null && validSelections.contains(player.getHeldItem().getItem())) {
|
||||
stack = player.getHeldItem().copy();
|
||||
ItemStack heldItem = player.getHeldItem();
|
||||
heldItem.stackSize--;
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (this.stack != null && player.getHeldItem().getItem() instanceof IToolWrench) {
|
||||
this.stack.getItem().onItemRightClick(this.stack, world, player);
|
||||
|
||||
if (stack != null && player.getHeldItem().getItem() instanceof IToolWrench) {
|
||||
stack.getItem().onItemRightClick(stack, world, player);
|
||||
}
|
||||
}
|
||||
if (this.stack != null) {
|
||||
this.stack.getItem().onItemRightClick(this.stack, world, player);
|
||||
|
||||
if (stack != null) {
|
||||
stack.getItem().onItemRightClick(stack, world, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user