mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
needle punch fuck machine
This commit is contained in:
parent
6b1d61166f
commit
0cf9d88e36
@ -0,0 +1,74 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.inventory.SlotCraftingOutput;
|
||||
import com.hbm.inventory.SlotNonRetarded;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemAssemblyTemplate;
|
||||
import com.hbm.items.machine.ItemMachineUpgrade;
|
||||
import com.hbm.util.InventoryUtil;
|
||||
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerMachineAssemblyMachine extends ContainerBase {
|
||||
|
||||
public ContainerMachineAssemblyMachine(InventoryPlayer invPlayer, IInventory assembler) {
|
||||
super(invPlayer, assembler);
|
||||
|
||||
// Battery
|
||||
this.addSlotToContainer(new SlotNonRetarded(assembler, 0, 152, 81));
|
||||
// Schematic
|
||||
this.addSlotToContainer(new SlotNonRetarded(assembler, 1, 35, 126));
|
||||
// Upgrades
|
||||
this.addSlots(assembler, 2, 152, 108, 2, 1);
|
||||
// Input
|
||||
this.addSlots(assembler, 4, 8, 18, 4, 3);
|
||||
// Output
|
||||
this.addSlotToContainer(new SlotCraftingOutput(invPlayer.player, assembler, 16, 98, 45));
|
||||
|
||||
this.playerInv(invPlayer, 8, 174);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
||||
ItemStack slotOriginal = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(index);
|
||||
|
||||
if(slot != null && slot.getHasStack()) {
|
||||
ItemStack slotStack = slot.getStack();
|
||||
slotOriginal = slotStack.copy();
|
||||
|
||||
if(index <= tile.getSizeInventory() - 1) {
|
||||
SlotCraftingOutput.checkAchievements(player, slotStack);
|
||||
if(!this.mergeItemStack(slotStack, tile.getSizeInventory(), this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
|
||||
if(slotOriginal.getItem() instanceof IBatteryItem || slotOriginal.getItem() == ModItems.battery_creative) {
|
||||
if(!this.mergeItemStack(slotStack, 0, 1, false)) return null;
|
||||
} else if(slotOriginal.getItem() instanceof ItemAssemblyTemplate) {
|
||||
if(!this.mergeItemStack(slotStack, 1, 2, false)) return null;
|
||||
} else if(slotOriginal.getItem() instanceof ItemMachineUpgrade) {
|
||||
if(!this.mergeItemStack(slotStack, 2, 4, false)) return null;
|
||||
} else {
|
||||
if(!InventoryUtil.mergeItemStack(this.inventorySlots, slotStack, 4, 7, false)) return null;
|
||||
}
|
||||
}
|
||||
|
||||
if(slotStack.stackSize == 0) {
|
||||
slot.putStack(null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
slot.onPickupFromSlot(player, slotStack);
|
||||
}
|
||||
|
||||
return slotOriginal;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,121 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.container.ContainerMachineAssemblyMachine;
|
||||
import com.hbm.inventory.recipes.AssemblyMachineRecipes;
|
||||
import com.hbm.inventory.recipes.loader.GenericRecipe;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineAssemblyMachine;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIMachineAssemblyMachine extends GuiInfoContainer {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_assembler.png");
|
||||
private TileEntityMachineAssemblyMachine assembler;
|
||||
|
||||
public GUIMachineAssemblyMachine(InventoryPlayer invPlayer, TileEntityMachineAssemblyMachine tedf) {
|
||||
super(new ContainerMachineAssemblyMachine(invPlayer, tedf));
|
||||
assembler = tedf;
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 256;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float f) {
|
||||
super.drawScreen(mouseX, mouseY, f);
|
||||
|
||||
assembler.inputTank.renderTankInfo(this, mouseX, mouseY, guiLeft + 8, guiTop + 115, 34, 16);
|
||||
assembler.outputTank.renderTankInfo(this, mouseX, mouseY, guiLeft + 80, guiTop + 115, 34, 16);
|
||||
|
||||
this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 152, guiTop + 18, 16, 61, assembler.power, assembler.maxPower);
|
||||
|
||||
if(guiLeft + 7 <= mouseX && guiLeft + 7 + 18 > mouseX && guiTop + 125 < mouseY && guiTop + 125 + 18 >= mouseY) {
|
||||
if(this.assembler.assemblerModule.recipe != null && AssemblyMachineRecipes.INSTANCE.recipeNameMap.containsKey(this.assembler.assemblerModule.recipe)) {
|
||||
GenericRecipe recipe = (GenericRecipe) AssemblyMachineRecipes.INSTANCE.recipeNameMap.get(this.assembler.assemblerModule.recipe);
|
||||
this.func_146283_a(recipe.print(), mouseX, mouseY);
|
||||
} else {
|
||||
this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + "Click to set recipe", mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int button) {
|
||||
super.mouseClicked(x, y, button);
|
||||
|
||||
if(this.checkClick(x, y, 7, 125, 18, 18)) GUIScreenRecipeSelector.openSelector(AssemblyMachineRecipes.INSTANCE, assembler, assembler.assemblerModule.recipe, 0, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.assembler.hasCustomInventoryName() ? this.assembler.getInventoryName() : I18n.format(this.assembler.getInventoryName());
|
||||
|
||||
this.fontRendererObj.drawString(name, 70 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
int p = (int) (assembler.power * 61 / assembler.maxPower);
|
||||
drawTexturedModalRect(guiLeft + 152, guiTop + 79 - p, 176, 61 - p, 16, p);
|
||||
|
||||
if(assembler.assemblerModule.progress > 0) {
|
||||
int j = (int) Math.ceil(70 * assembler.assemblerModule.progress);
|
||||
drawTexturedModalRect(guiLeft + 62, guiTop + 126, 176, 61, j, 16);
|
||||
}
|
||||
|
||||
GenericRecipe recipe = AssemblyMachineRecipes.INSTANCE.recipeNameMap.get(assembler.assemblerModule.recipe);
|
||||
|
||||
/// LEFT LED
|
||||
if(assembler.didProcess) {
|
||||
drawTexturedModalRect(guiLeft + 51, guiTop + 121, 195, 0, 3, 6);
|
||||
} else if(recipe != null) {
|
||||
drawTexturedModalRect(guiLeft + 51, guiTop + 121, 192, 0, 3, 6);
|
||||
}
|
||||
|
||||
/// RIGHT LED
|
||||
if(assembler.didProcess) {
|
||||
drawTexturedModalRect(guiLeft + 56, guiTop + 121, 195, 0, 3, 6);
|
||||
} else if(recipe != null && assembler.power >= recipe.power) {
|
||||
drawTexturedModalRect(guiLeft + 56, guiTop + 121, 192, 0, 3, 6);
|
||||
}
|
||||
|
||||
this.renderItem(recipe != null ? recipe.getIcon() : TEMPLATE_FOLDER, 8, 126);
|
||||
|
||||
if(recipe != null && recipe.inputItem != null) {
|
||||
for(int i = 0; i < recipe.inputItem.length; i++) {
|
||||
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(assembler.assemblerModule.inputSlots[i]);
|
||||
if(!slot.getHasStack()) this.renderItem(recipe.inputItem[i].extractForCyclingDisplay(20), slot.xDisplayPosition, slot.yDisplayPosition, 10F);
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glColor4f(1F, 1F, 1F, 0.5F);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
this.zLevel = 300F;
|
||||
for(int i = 0; i < recipe.inputItem.length; i++) {
|
||||
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(assembler.assemblerModule.inputSlots[i]);
|
||||
if(!slot.getHasStack()) drawTexturedModalRect(guiLeft + slot.xDisplayPosition, guiTop + slot.yDisplayPosition, slot.xDisplayPosition, slot.yDisplayPosition, 16, 16);
|
||||
}
|
||||
this.zLevel = 0F;
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
assembler.inputTank.renderTank(guiLeft + 8, guiTop + 115, this.zLevel, 34, 16, 1);
|
||||
assembler.outputTank.renderTank(guiLeft + 80, guiTop + 115, this.zLevel, 34, 16, 1);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package com.hbm.inventory.recipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static com.hbm.inventory.OreDictManager.*;
|
||||
import static com.hbm.inventory.material.Mats.*;
|
||||
|
||||
import com.hbm.inventory.FluidStack;
|
||||
import com.hbm.inventory.RecipesCommon.AStack;
|
||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
import com.hbm.inventory.RecipesCommon.OreDictStack;
|
||||
import com.hbm.inventory.recipes.loader.GenericRecipe;
|
||||
import com.hbm.inventory.recipes.loader.GenericRecipes;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemFluidIcon;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class AssemblyMachineRecipes extends GenericRecipes<GenericRecipe> {
|
||||
|
||||
public static final AssemblyMachineRecipes INSTANCE = new AssemblyMachineRecipes();
|
||||
|
||||
@Override public int inputItemLimit() { return 12; }
|
||||
@Override public int inputFluidLimit() { return 1; }
|
||||
@Override public int outputItemLimit() { return 1; }
|
||||
@Override public int outputFluidLimit() { return 1; }
|
||||
|
||||
@Override public String getFileName() { return "hbmAsemblyMachine.json"; }
|
||||
@Override public GenericRecipe instantiateRecipe(String name) { return new GenericRecipe(name); }
|
||||
|
||||
@Override
|
||||
public void registerDefaults() {
|
||||
|
||||
this.register(new GenericRecipe("ass.test").setup(100, 1_000)
|
||||
.inputItems(new OreDictStack(STEEL.ingot(), 5))
|
||||
.outputItems(new ItemStack(ModItems.plate_welded, 1, MAT_STEEL.id)));
|
||||
}
|
||||
|
||||
public static HashMap getRecipes() {
|
||||
HashMap<Object, Object> recipes = new HashMap<Object, Object>();
|
||||
|
||||
for(GenericRecipe recipe : INSTANCE.recipeOrderedList) {
|
||||
List input = new ArrayList();
|
||||
if(recipe.inputItem != null) for(AStack stack : recipe.inputItem) input.add(stack);
|
||||
if(recipe.inputFluid != null) for(FluidStack stack : recipe.inputFluid) input.add(ItemFluidIcon.make(stack));
|
||||
List output = new ArrayList();
|
||||
if(recipe.outputItem != null) for(IOutput stack : recipe.outputItem) output.add(stack.getAllPossibilities());
|
||||
if(recipe.outputFluid != null) for(FluidStack stack : recipe.outputFluid) output.add(ItemFluidIcon.make(stack));
|
||||
recipes.put(input.toArray(), output.toArray());
|
||||
}
|
||||
|
||||
return recipes;
|
||||
}
|
||||
}
|
||||
@ -229,12 +229,11 @@ public class AnvilRecipes extends SerializableRecipe {
|
||||
int ukModifier = 1;
|
||||
constructionRecipes.add(new AnvilConstructionRecipe(
|
||||
new AStack[] {
|
||||
new OreDictStack(KEY_CLEARGLASS, 4 * ukModifier),
|
||||
new OreDictStack(STEEL.ingot(), 8 * ukModifier),
|
||||
new OreDictStack(CU.ingot(), 8 * ukModifier),
|
||||
new OreDictStack(CU.plate(), 4 * ukModifier),
|
||||
new ComparableStack(ModItems.motor, 2 * ukModifier),
|
||||
new ComparableStack(ModItems.circuit, 4 * ukModifier, EnumCircuitType.VACUUM_TUBE.ordinal())
|
||||
}, new AnvilOutput(new ItemStack(ModBlocks.machine_assembler))).setTier(2));
|
||||
}, new AnvilOutput(new ItemStack(ModBlocks.machine_assembly_machine))).setTier(2));
|
||||
|
||||
constructionRecipes.add(new AnvilConstructionRecipe(
|
||||
new AStack[] {
|
||||
|
||||
@ -83,6 +83,7 @@ public abstract class SerializableRecipe {
|
||||
recipeHandlers.add(new PedestalRecipes());
|
||||
|
||||
//GENERIC
|
||||
recipeHandlers.add(AssemblyMachineRecipes.INSTANCE);
|
||||
recipeHandlers.add(ChemicalPlantRecipes.INSTANCE);
|
||||
|
||||
recipeHandlers.add(new MatDistribution());
|
||||
|
||||
@ -267,6 +267,7 @@ public class ClientProxy extends ServerProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityChimneyIndustrial.class, new RenderChimneyIndustrial());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineMiningLaser.class, new RenderLaserMiner());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineAssembler.class, new RenderAssembler());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineAssemblyMachine.class, new RenderAssemblyMachine());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineAssemfac.class, new RenderAssemfac());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineChemplant.class, new RenderChemplant());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineChemicalPlant.class, new RenderChemicalPlant());
|
||||
|
||||
@ -140,6 +140,7 @@ public class ResourceManager {
|
||||
public static final IModelCustom assembler_cog = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/assembler_new_cog.obj"));
|
||||
public static final IModelCustom assembler_slider = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/assembler_new_slider.obj"));
|
||||
public static final IModelCustom assembler_arm = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/assembler_new_arm.obj"));
|
||||
public static final IModelCustom assembly_machine = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/assembly_machine.obj"));
|
||||
public static final IModelCustom assemfac = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/assemfac.obj"));
|
||||
|
||||
//Chemplant
|
||||
@ -574,6 +575,7 @@ public class ResourceManager {
|
||||
public static final ResourceLocation assembler_cog_tex = new ResourceLocation(RefStrings.MODID, "textures/models/assembler_cog_new.png");
|
||||
public static final ResourceLocation assembler_slider_tex = new ResourceLocation(RefStrings.MODID, "textures/models/assembler_slider_new.png");
|
||||
public static final ResourceLocation assembler_arm_tex = new ResourceLocation(RefStrings.MODID, "textures/models/assembler_arm_new.png");
|
||||
public static final ResourceLocation assembly_machine_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/assembly_machine.png");
|
||||
public static final ResourceLocation assemfac_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/assemfac.png");
|
||||
|
||||
//Chemplant
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.hbm.module.machine;
|
||||
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.inventory.recipes.AssemblyMachineRecipes;
|
||||
import com.hbm.inventory.recipes.loader.GenericRecipe;
|
||||
|
||||
import api.hbm.energymk2.IEnergyHandlerMK2;
|
||||
@ -18,7 +19,7 @@ public class ModuleMachineAssembler extends ModuleMachineBase {
|
||||
|
||||
@Override
|
||||
public GenericRecipe getRecipe() {
|
||||
return null;
|
||||
return AssemblyMachineRecipes.INSTANCE.recipeNameMap.get(this.recipe);
|
||||
}
|
||||
|
||||
public ModuleMachineAssembler itemInput(int from) { for(int i = 0; i < inputSlots.length; i++) inputSlots[i] = from + i; return this; }
|
||||
|
||||
@ -0,0 +1,157 @@
|
||||
package com.hbm.render.tileentity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.inventory.recipes.AssemblyMachineRecipes;
|
||||
import com.hbm.inventory.recipes.loader.GenericRecipe;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.main.ResourceManager;
|
||||
import com.hbm.render.item.ItemRenderBase;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineAssemblyMachine;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
public class RenderAssemblyMachine extends TileEntitySpecialRenderer implements IItemRendererProvider {
|
||||
|
||||
public static EntityItem dummy;
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float interp) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y, z + 0.5);
|
||||
GL11.glRotated(90, 0, 1, 0);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
|
||||
switch(tileEntity.getBlockMetadata() - BlockDummyable.offset) {
|
||||
case 2: GL11.glRotatef(0, 0F, 1F, 0F); break;
|
||||
case 4: GL11.glRotatef(90, 0F, 1F, 0F); break;
|
||||
case 3: GL11.glRotatef(180, 0F, 1F, 0F); break;
|
||||
case 5: GL11.glRotatef(270, 0F, 1F, 0F); break;
|
||||
}
|
||||
|
||||
TileEntityMachineAssemblyMachine assembler = (TileEntityMachineAssemblyMachine) tileEntity;
|
||||
|
||||
bindTexture(ResourceManager.assembly_machine_tex);
|
||||
ResourceManager.assembly_machine.renderPart("Base");
|
||||
if(assembler.frame) ResourceManager.assembly_machine.renderPart("Frame");
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
double spin = BobMathUtil.interp(assembler.prevRing, assembler.ring, interp);
|
||||
double[] arm1 = assembler.arms[0].getPositions(interp);
|
||||
double[] arm2 = assembler.arms[1].getPositions(interp);
|
||||
|
||||
// arm1 = arm2 = new double[] {60, -15, 15, -0.25}; // heart
|
||||
|
||||
GL11.glRotated(spin, 0, 1, 0);
|
||||
ResourceManager.assembly_machine.renderPart("Ring");
|
||||
|
||||
GL11.glPushMatrix(); {
|
||||
GL11.glTranslated(0, 1.625, 0.9375);
|
||||
GL11.glRotated(arm1[0], 1, 0, 0);
|
||||
GL11.glTranslated(0, -1.625, -0.9375);
|
||||
ResourceManager.assembly_machine.renderPart("ArmLower1");
|
||||
|
||||
GL11.glTranslated(0, 2.375, 0.9375);
|
||||
GL11.glRotated(arm1[1], 1, 0, 0);
|
||||
GL11.glTranslated(0, -2.375, -0.9375);
|
||||
ResourceManager.assembly_machine.renderPart("ArmUpper1");
|
||||
|
||||
GL11.glTranslated(0, 2.375, 0.4375);
|
||||
GL11.glRotated(arm1[2], 1, 0, 0);
|
||||
GL11.glTranslated(0, -2.375, -0.4375);
|
||||
ResourceManager.assembly_machine.renderPart("Head1");
|
||||
GL11.glTranslated(0, arm1[3], 0);
|
||||
ResourceManager.assembly_machine.renderPart("Spike1");
|
||||
} GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix(); {
|
||||
GL11.glTranslated(0, 1.625, -0.9375);
|
||||
GL11.glRotated(-arm2[0], 1, 0, 0);
|
||||
GL11.glTranslated(0, -1.625, 0.9375);
|
||||
ResourceManager.assembly_machine.renderPart("ArmLower2");
|
||||
|
||||
GL11.glTranslated(0, 2.375, -0.9375);
|
||||
GL11.glRotated(-arm2[1], 1, 0, 0);
|
||||
GL11.glTranslated(0, -2.375, 0.9375);
|
||||
ResourceManager.assembly_machine.renderPart("ArmUpper2");
|
||||
|
||||
GL11.glTranslated(0, 2.375, -0.4375);
|
||||
GL11.glRotated(-arm2[2], 1, 0, 0);
|
||||
GL11.glTranslated(0, -2.375, 0.4375);
|
||||
ResourceManager.assembly_machine.renderPart("Head2");
|
||||
GL11.glTranslated(0, arm2[3], 0);
|
||||
ResourceManager.assembly_machine.renderPart("Spike2");
|
||||
} GL11.glPopMatrix();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
|
||||
GenericRecipe recipe = AssemblyMachineRecipes.INSTANCE.recipeNameMap.get(assembler.assemblerModule.recipe);
|
||||
if(recipe != null && MainRegistry.proxy.me().getDistanceSq(tileEntity.xCoord + 0.5, tileEntity.yCoord + 1, tileEntity.zCoord + 0.5) < 35 * 35) {
|
||||
|
||||
GL11.glRotated(90, 0, 1, 0);
|
||||
GL11.glTranslated(0, 1.0625, 0);
|
||||
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
ItemStack stack = recipe.getIcon();
|
||||
|
||||
if(!(stack.getItemSpriteNumber() == 0 && stack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType()))) {
|
||||
GL11.glRotated(-90, 1, 0, 0);
|
||||
GL11.glTranslated(0, -0.25, 0);
|
||||
}
|
||||
|
||||
GL11.glScaled(1.25, 1.25, 1.25);
|
||||
|
||||
if(dummy == null || dummy.worldObj != tileEntity.getWorldObj()) dummy = new EntityItem(tileEntity.getWorldObj(), 0, 0, 0, stack);
|
||||
dummy.setEntityItemStack(stack);
|
||||
dummy.hoverStart = 0.0F;
|
||||
|
||||
RenderItem.renderInFrame = true;
|
||||
RenderManager.instance.renderEntityWithPosYaw(dummy, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
RenderItem.renderInFrame = false;
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemForRenderer() {
|
||||
return Item.getItemFromBlock(ModBlocks.machine_assembly_machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemRenderer getRenderer() {
|
||||
|
||||
return new ItemRenderBase() {
|
||||
|
||||
public void renderInventory() {
|
||||
GL11.glTranslated(0, -2.75, 0);
|
||||
GL11.glScaled(4.5, 4.5, 4.5);
|
||||
}
|
||||
public void renderCommonWithStack(ItemStack item) {
|
||||
GL11.glRotated(90, 0, 1, 0);
|
||||
GL11.glScaled(0.75, 0.75, 0.75);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
bindTexture(ResourceManager.assembly_machine_tex);
|
||||
ResourceManager.assembly_machine.renderAll();
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
}};
|
||||
}
|
||||
}
|
||||
@ -340,6 +340,7 @@ public class TileMappings {
|
||||
put(TileEntityMachineCombustionEngine.class, "tileentity_combustion_engine");
|
||||
|
||||
put(TileEntityMachineAssembler.class, "tileentity_assembly_machine");
|
||||
put(TileEntityMachineAssemblyMachine.class, "tileentity_assemblymachine");
|
||||
put(TileEntityMachineAssemfac.class, "tileentity_assemfac");
|
||||
put(TileEntityMachineChemplant.class, "tileentity_chemical_plant");
|
||||
put(TileEntityMachineChemicalPlant.class, "tileentity_chemicalplant");
|
||||
|
||||
@ -31,6 +31,7 @@ import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@Deprecated
|
||||
public class TileEntityMachineAssembler extends TileEntityMachineAssemblerBase implements IUpgradeInfoProvider {
|
||||
|
||||
public int recipe = -1;
|
||||
|
||||
@ -22,6 +22,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
@Deprecated
|
||||
public abstract class TileEntityMachineAssemblerBase extends TileEntityMachineBase implements IEnergyReceiverMK2, IGUIProvider {
|
||||
|
||||
public long power;
|
||||
|
||||
@ -2,14 +2,15 @@ package com.hbm.tileentity.machine;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.interfaces.IControlReceiver;
|
||||
import com.hbm.inventory.UpgradeManagerNT;
|
||||
import com.hbm.inventory.container.ContainerMachineChemicalPlant;
|
||||
import com.hbm.inventory.container.ContainerMachineAssemblyMachine;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.inventory.gui.GUIMachineChemicalPlant;
|
||||
import com.hbm.inventory.gui.GUIMachineAssemblyMachine;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemMachineUpgrade;
|
||||
import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType;
|
||||
@ -33,7 +34,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
@ -51,6 +51,13 @@ public class TileEntityMachineAssemblyMachine extends TileEntityMachineBase impl
|
||||
private AudioWrapper audio;
|
||||
|
||||
public ModuleMachineAssembler assemblerModule;
|
||||
|
||||
public AssemblerArm[] arms = new AssemblerArm[2];
|
||||
public double prevRing;
|
||||
public double ring;
|
||||
public double ringSpeed;
|
||||
public double ringTarget;
|
||||
public int ringDelay;
|
||||
|
||||
public UpgradeManagerNT upgradeManager = new UpgradeManagerNT(this);
|
||||
|
||||
@ -59,6 +66,8 @@ public class TileEntityMachineAssemblyMachine extends TileEntityMachineBase impl
|
||||
this.inputTank = new FluidTank(Fluids.NONE, 32_000);
|
||||
this.outputTank = new FluidTank(Fluids.NONE, 32_000);
|
||||
|
||||
for(int i = 0; i < this.arms.length; i++) this.arms[i] = new AssemblerArm();
|
||||
|
||||
this.assemblerModule = new ModuleMachineAssembler(0, this, slots)
|
||||
.itemInput(4).itemOutput(16)
|
||||
.fluidInput(inputTank).fluidOutput(outputTank);
|
||||
@ -128,11 +137,50 @@ public class TileEntityMachineAssemblyMachine extends TileEntityMachineBase impl
|
||||
audio = null;
|
||||
}
|
||||
}
|
||||
|
||||
for(AssemblerArm arm : arms) {
|
||||
arm.updateInterp();
|
||||
if(didProcess) {
|
||||
arm.updateArm();
|
||||
} else{
|
||||
arm.returnToNullPos();
|
||||
}
|
||||
}
|
||||
|
||||
this.prevRing = this.ring;
|
||||
|
||||
if(didProcess) {
|
||||
if(this.ring != this.ringTarget) {
|
||||
double ringDelta = Math.abs(this.ringTarget - this.ring);
|
||||
if(ringDelta <= this.ringSpeed) this.ring = this.ringTarget;
|
||||
if(this.ringTarget > this.ring) this.ring += this.ringSpeed;
|
||||
if(this.ringTarget < this.ring) this.ring -= this.ringSpeed;
|
||||
if(this.ringTarget == this.ring) {
|
||||
if(ringTarget >= 360) {
|
||||
this.ringTarget -= 360D;
|
||||
this.ring -= 360D;
|
||||
this.prevRing -= 360D;
|
||||
}
|
||||
if(ringTarget <= -360) {
|
||||
this.ringTarget += 360D;
|
||||
this.ring += 360D;
|
||||
this.prevRing += 360D;
|
||||
}
|
||||
this.ringDelay = 20 + worldObj.rand.nextInt(21);
|
||||
}
|
||||
} else {
|
||||
if(this.ringDelay > 0) this.ringDelay--;
|
||||
if(this.ringDelay <= 0) {
|
||||
this.ringTarget += (worldObj.rand.nextDouble() * 2 - 1) * 135;
|
||||
this.ringSpeed = 10D + worldObj.rand.nextDouble() * 5D;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public AudioWrapper createAudioLoop() {
|
||||
return MainRegistry.proxy.getLoopedSound("hbm:block.assembler", xCoord, yCoord, zCoord, 1F, 15F, 1.0F, 20);
|
||||
return MainRegistry.proxy.getLoopedSound("hbm:block.chemicalPlant", xCoord, yCoord, zCoord, 1F, 15F, 1.0F, 20);
|
||||
}
|
||||
|
||||
@Override public void onChunkUnload() {
|
||||
@ -216,6 +264,11 @@ public class TileEntityMachineAssemblyMachine extends TileEntityMachineBase impl
|
||||
return i == 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return new int[] {4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
|
||||
}
|
||||
|
||||
@Override public long getPower() { return power; }
|
||||
@Override public void setPower(long power) { this.power = power; }
|
||||
@Override public long getMaxPower() { return maxPower; }
|
||||
@ -283,4 +336,135 @@ public class TileEntityMachineAssemblyMachine extends TileEntityMachineBase impl
|
||||
upgrades.put(UpgradeType.OVERDRIVE, 3);
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
public static class AssemblerArm {
|
||||
|
||||
public double[] angles = new double[4];
|
||||
public double[] prevAngles = new double[4];
|
||||
public double[] targetAngles = new double[4];
|
||||
public double[] speed = new double[4];
|
||||
|
||||
Random rand = new Random();
|
||||
ArmActionState state = ArmActionState.ASSUME_POSITION;
|
||||
int actionDelay = 0;
|
||||
|
||||
public static enum ArmActionState {
|
||||
ASSUME_POSITION,
|
||||
EXTEND_STRIKER,
|
||||
RETRACT_STRIKER
|
||||
}
|
||||
|
||||
public AssemblerArm() {
|
||||
this.resetSpeed();
|
||||
}
|
||||
|
||||
private void updateInterp() {
|
||||
for(int i = 0; i < angles.length; i++) {
|
||||
prevAngles[i] = angles[i];
|
||||
}
|
||||
}
|
||||
|
||||
private void returnToNullPos() {
|
||||
for(int i = 0; i < 4; i++) this.targetAngles[i] = 0;
|
||||
for(int i = 0; i < 3; i++) this.speed[i] = 3;
|
||||
this.speed[3] = 0.25;
|
||||
this.state = ArmActionState.RETRACT_STRIKER;
|
||||
|
||||
this.move();
|
||||
}
|
||||
|
||||
private void resetSpeed() {
|
||||
speed[0] = 15; //Pivot
|
||||
speed[1] = 15; //Arm
|
||||
speed[2] = 15; //Piston
|
||||
speed[3] = 0.5; //Striker
|
||||
}
|
||||
|
||||
public void updateArm() {
|
||||
resetSpeed();
|
||||
|
||||
if(actionDelay > 0) {
|
||||
actionDelay--;
|
||||
return;
|
||||
}
|
||||
|
||||
switch(state) {
|
||||
// Move. If done moving, set a delay and progress to EXTEND
|
||||
case ASSUME_POSITION:
|
||||
if(move()) {
|
||||
actionDelay = 2;
|
||||
state = ArmActionState.EXTEND_STRIKER;
|
||||
targetAngles[3] = -0.75D;
|
||||
}
|
||||
break;
|
||||
case EXTEND_STRIKER:
|
||||
if(move()) {
|
||||
state = ArmActionState.RETRACT_STRIKER;
|
||||
targetAngles[3] = 0D;
|
||||
}
|
||||
break;
|
||||
case RETRACT_STRIKER:
|
||||
if(move()) {
|
||||
actionDelay = 2 + rand.nextInt(5);
|
||||
chooseNewArmPoistion();
|
||||
state = ArmActionState.ASSUME_POSITION;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private double[][] pos = new double[][] { // possible positions for the arms
|
||||
{45, -15, -5},
|
||||
{15, 15, -15},
|
||||
{25, 10, -15},
|
||||
{30, 0, -10},
|
||||
{70, -10, -25},
|
||||
}; // sure it's not truly random like with the old assemfac, but at least now the striker always hits the center and doesn't clip through the board
|
||||
|
||||
public void chooseNewArmPoistion() {
|
||||
int chosen = rand.nextInt(pos.length);
|
||||
this.targetAngles[0] = pos[chosen][0];
|
||||
this.targetAngles[1] = pos[chosen][1];
|
||||
this.targetAngles[2] = pos[chosen][2];
|
||||
}
|
||||
|
||||
private boolean move() {
|
||||
boolean didMove = false;
|
||||
|
||||
for(int i = 0; i < angles.length; i++) {
|
||||
if(angles[i] == targetAngles[i])
|
||||
continue;
|
||||
|
||||
didMove = true;
|
||||
|
||||
double angle = angles[i];
|
||||
double target = targetAngles[i];
|
||||
double turn = speed[i];
|
||||
double delta = Math.abs(angle - target);
|
||||
|
||||
if(delta <= turn) {
|
||||
angles[i] = targetAngles[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
if(angle < target) {
|
||||
angles[i] += turn;
|
||||
} else {
|
||||
angles[i] -= turn;
|
||||
}
|
||||
}
|
||||
|
||||
return !didMove;
|
||||
}
|
||||
|
||||
public double[] getPositions(float interp) {
|
||||
return new double[] {
|
||||
BobMathUtil.interp(this.prevAngles[0], this.angles[0], interp),
|
||||
BobMathUtil.interp(this.prevAngles[1], this.angles[1], interp),
|
||||
BobMathUtil.interp(this.prevAngles[2], this.angles[2], interp),
|
||||
BobMathUtil.interp(this.prevAngles[3], this.angles[3], interp)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Loading…
x
Reference in New Issue
Block a user