yeah whatever this is

This commit is contained in:
Bob 2022-09-06 22:22:12 +02:00
parent b72355fc06
commit 1f58ab69a7
12 changed files with 2796 additions and 11 deletions

View File

@ -633,6 +633,7 @@ public class ModBlocks {
public static Block furnace_steel;
public static Block machine_stirling;
public static Block machine_stirling_steel;
public static Block machine_sawmill;
public static Block machine_difurnace_off;
public static Block machine_difurnace_on;
@ -1806,6 +1807,7 @@ public class ModBlocks {
furnace_steel = new FurnaceSteel().setBlockName("furnace_steel").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
machine_stirling = new MachineStirling().setBlockName("machine_stirling").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
machine_stirling_steel = new MachineStirling().setBlockName("machine_stirling_steel").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
machine_sawmill = new MachineSawmill().setBlockName("machine_sawmill").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
machine_difurnace_off = new MachineDiFurnace(false).setBlockName("machine_difurnace_off").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
machine_difurnace_on = new MachineDiFurnace(true).setBlockName("machine_difurnace_on").setHardness(5.0F).setLightLevel(1.0F).setResistance(10.0F);
@ -2990,6 +2992,7 @@ public class ModBlocks {
register(furnace_steel);
register(machine_stirling);
register(machine_stirling_steel);
register(machine_sawmill);
GameRegistry.registerBlock(machine_difurnace_off, machine_difurnace_off.getUnlocalizedName());
GameRegistry.registerBlock(machine_difurnace_on, machine_difurnace_on.getUnlocalizedName());
GameRegistry.registerBlock(machine_difurnace_rtg_off, machine_difurnace_rtg_off.getUnlocalizedName());

View File

@ -0,0 +1,165 @@
package com.hbm.blocks.machine;
import java.util.ArrayList;
import java.util.List;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ITooltipProvider;
import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.machine.TileEntitySawmill;
import com.hbm.util.BobMathUtil;
import com.hbm.util.I18nUtil;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
import net.minecraftforge.common.util.ForgeDirection;
public class MachineSawmill extends BlockDummyable implements ILookOverlay, ITooltipProvider {
public MachineSawmill() {
super(Material.iron);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12)
return new TileEntitySawmill();
if(meta >= extra)
return new TileEntityProxyCombo().inventory();
return null;
}
@Override
public int[] getDimensions() {
return new int[] {1, 0, 1, 1, 1, 1};
}
@Override
public int getOffset() {
return 1;
}
@Override
public void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) {
super.fillSpace(world, x, y, z, dir, o);
x = x + dir.offsetX * o;
z = z + dir.offsetZ * o;
this.makeExtra(world, x + 1, y, z);
this.makeExtra(world, x - 1, y, z);
this.makeExtra(world, x, y, z + 1);
this.makeExtra(world, x, y, z - 1);
}
@Override
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;
} else if(!player.isSneaking()) {
int[] pos = this.findCore(world, x, y, z);
if(pos == null)
return false;
TileEntitySawmill sawmill = (TileEntitySawmill)world.getTileEntity(pos[0], pos[1], pos[2]);
if(sawmill.slots[1] != null || sawmill.slots[2] != null) {
for(int i = 1; i < 3; i++) {
if(sawmill.slots[i] != null) {
if(!player.inventory.addItemStackToInventory(sawmill.slots[i].copy())) {
player.dropPlayerItemWithRandomChoice(sawmill.slots[i].copy(), false);
}
sawmill.slots[i] = null;
}
}
player.inventoryContainer.detectAndSendChanges();
sawmill.markDirty();
return true;
} else {
if(sawmill.slots[0] == null && player.getHeldItem() != null && sawmill.getOutput(player.getHeldItem()) != null) {
sawmill.slots[0] = player.getHeldItem().copy();
sawmill.slots[0].stackSize = 1;
player.getHeldItem().stackSize--;
sawmill.markDirty();
player.inventoryContainer.detectAndSendChanges();
return true;
}
}
}
return false;
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) { }
@Override
public void printHook(Pre event, World world, int x, int y, int z) {
int[] pos = this.findCore(world, x, y, z);
if(pos == null)
return;
TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]);
if(!(te instanceof TileEntitySawmill))
return;
TileEntitySawmill stirling = (TileEntitySawmill) te;
List<String> text = new ArrayList();
text.add(stirling.heat + "TU/t");
double percent = (double) stirling.heat / (double) 300;
int color = ((int) (0xFF - 0xFF * percent)) << 16 | ((int)(0xFF * percent) << 8);
if(percent > 1D)
color = 0xff0000;
text.add("&[" + color + "&]" + ((stirling.heat * 1000 / 300) / 10D) + "%");
int limiter = stirling.progress * 26 / stirling.processingTime;
String bar = EnumChatFormatting.GREEN + "[ ";
for(int i = 0; i < 25; i++) {
if(i == limiter) {
bar += EnumChatFormatting.RESET;
}
bar += "";
}
bar += EnumChatFormatting.GREEN + " ]";
text.add(bar);
for(int i = 0; i < 3; i++) {
if(stirling.slots[i] != null) {
text.add((i == 0 ? (EnumChatFormatting.GREEN + "-> ") : (EnumChatFormatting.RED + "<- ")) + EnumChatFormatting.RESET + stirling.slots[i].getDisplayName() + (stirling.slots[i].stackSize > 1 ? " x" + stirling.slots[i].stackSize : ""));
}
}
if(stirling.heat > 300) {
text.add("&[" + (BobMathUtil.getBlink() ? 0xff0000 : 0xffff00) + "&]! ! ! OVERSPEED ! ! !");
}
if(!stirling.hasBlade) {
text.add("&[" + 0xff0000 + "&]Blade missing!");
}
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
}
}

View File

@ -263,6 +263,7 @@ public class ClientProxy extends ServerProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityHeaterFirebox.class, new RenderFirebox());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityHeaterOilburner.class, new RenderOilburner());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityStirling.class, new RenderStirling());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySawmill.class, new RenderSawmill());
//AMS
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAMSBase.class, new RenderAMSBase());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAMSEmitter.class, new RenderAMSEmitter());

View File

@ -63,6 +63,7 @@ public class ResourceManager {
//Heat Engines
public static final IModelCustom stirling = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/machines/stirling.obj"));
public static final IModelCustom sawmill = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/machines/sawmill.obj"));
//Furnaces
public static final IModelCustom furnace_iron = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/machines/furnace_iron.obj"));
@ -383,6 +384,7 @@ public class ResourceManager {
//Heat Engines
public static final ResourceLocation stirling_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/stirling.png");
public static final ResourceLocation stirling_steel_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/stirling_steel.png");
public static final ResourceLocation sawmill_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/sawmill.png");
//Furnaces
public static final ResourceLocation furnace_iron_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/furnace_iron.png");

View File

@ -0,0 +1,89 @@
package com.hbm.render.tileentity;
import org.lwjgl.opengl.GL11;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ModBlocks;
import com.hbm.main.ResourceManager;
import com.hbm.render.item.ItemRenderBase;
import com.hbm.tileentity.machine.TileEntitySawmill;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.client.IItemRenderer;
public class RenderSawmill extends TileEntitySpecialRenderer implements IItemRendererProvider {
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float interp) {
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5D, y, z + 0.5D);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_CULL_FACE);
switch(tile.getBlockMetadata() - BlockDummyable.offset) {
case 3: GL11.glRotatef(0, 0F, 1F, 0F); break;
case 5: GL11.glRotatef(90, 0F, 1F, 0F); break;
case 2: GL11.glRotatef(180, 0F, 1F, 0F); break;
case 4: GL11.glRotatef(270, 0F, 1F, 0F); break;
}
TileEntitySawmill sawmill = (TileEntitySawmill) tile;
float rot = sawmill.lastSpin + (sawmill.spin - sawmill.lastSpin) * interp;
renderCommon(rot, sawmill.hasBlade);
GL11.glPopMatrix();
}
private void renderCommon(float rot, boolean hasBlade) {
bindTexture(ResourceManager.sawmill_tex);
ResourceManager.sawmill.renderPart("Main");
if(hasBlade) {
GL11.glPushMatrix();
GL11.glTranslated(0, 1.375, 0);
GL11.glRotatef(-rot * 2, 0, 0, 1);
GL11.glTranslated(0, -1.375, 0);
ResourceManager.sawmill.renderPart("Blade");
GL11.glPopMatrix();
}
GL11.glPushMatrix();
GL11.glTranslated(0.5625, 1.375, 0);
GL11.glRotatef(rot, 0, 0, 1);
GL11.glTranslated(-0.5625, -1.375, 0);
ResourceManager.sawmill.renderPart("GearLeft");
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslated(-0.5625, 1.375, 0);
GL11.glRotatef(-rot, 0, 0, 1);
GL11.glTranslated(0.5625, -1.375, 0);
ResourceManager.sawmill.renderPart("GearRight");
GL11.glPopMatrix();
}
@Override
public Item getItemForRenderer() {
return Item.getItemFromBlock(ModBlocks.machine_sawmill);
}
@Override
public IItemRenderer getRenderer() {
return new ItemRenderBase( ) {
public void renderInventory() {
GL11.glTranslated(0, -1.5, 0);
GL11.glScaled(3.25, 3.25, 3.25);
}
public void renderCommonWithStack(ItemStack item) {
GL11.glRotatef(90, 0F, 1F, 0F);
boolean cog = item.getItemDamage() != 1;
RenderSawmill.this.renderCommon(cog ? System.currentTimeMillis() % 3600 * 0.1F : 0, cog);
}};
}
}

View File

@ -249,6 +249,7 @@ public class TileMappings {
put(TileEntityFurnaceIron.class, "tileentity_furnace_iron");
put(TileEntityFurnaceSteel.class, "tileentity_furnace_steel");
put(TileEntityStirling.class, "tileentity_stirling");
put(TileEntitySawmill.class, "tileentity_sawmill");
put(TileEntityMachineAutocrafter.class, "tileentity_autocrafter");
put(TileEntityDiFurnaceRTG.class, "tileentity_rtg_difurnace");
put(TileEntityMachineRadiolysis.class, "tileentity_radiolysis");

View File

@ -0,0 +1,237 @@
package com.hbm.tileentity.machine;
import java.util.List;
import com.hbm.tileentity.INBTPacketReceiver;
import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.tileentity.machine.TileEntityMachineAutocrafter.InventoryCraftingAuto;
import com.hbm.util.ItemStackUtil;
import api.hbm.tile.IHeatSource;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
public class TileEntitySawmill extends TileEntityMachineBase {
public int heat;
public static final double diffusion = 0.1D;
private int warnCooldown = 0;
private int overspeed = 0;
public boolean hasBlade = true;
public int progress = 0;
public static final int processingTime = 600;
public float spin;
public float lastSpin;
public TileEntitySawmill() {
super(3);
}
@Override
public String getName() { return ""; }
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
if(hasBlade) {
tryPullHeat();
if(warnCooldown > 0)
warnCooldown--;
if(heat >= 100) {
ItemStack result = this.getOutput(slots[0]);
if(result != null) {
progress += heat / 10;
if(progress >= this.processingTime) {
progress = 0;
slots[0] = null;
slots[1] = result;
this.markDirty();
}
} else {
this.progress = 0;
}
} else {
this.progress = 0;
}
if(heat > 300) {
this.overspeed++;
if(overspeed > 60 && warnCooldown == 0) {
warnCooldown = 100;
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 1, zCoord + 0.5, "hbm:block.warnOverspeed", 2.0F, 1.0F);
}
if(overspeed > 300) {
this.hasBlade = false;
this.worldObj.newExplosion(null, xCoord + 0.5, yCoord + 1, zCoord + 0.5, 5F, false, false);
this.markDirty();
}
} else {
this.overspeed = 0;
}
} else {
this.overspeed = 0;
this.warnCooldown = 0;
}
NBTTagCompound data = new NBTTagCompound();
data.setInteger("heat", heat);
data.setInteger("progress", progress);
data.setBoolean("hasBlade", hasBlade);
NBTTagList list = new NBTTagList();
for(int i = 0; i < slots.length; i++) {
if(slots[i] != null) {
NBTTagCompound nbt1 = new NBTTagCompound();
nbt1.setByte("slot", (byte) i);
slots[i].writeToNBT(nbt1);
list.appendTag(nbt1);
}
}
data.setTag("items", list);
INBTPacketReceiver.networkPack(this, data, 150);
this.heat = 0;
} else {
float momentum = heat * 25F / ((float) 300);
this.lastSpin = this.spin;
this.spin += momentum;
if(this.spin >= 360F) {
this.spin -= 360F;
this.lastSpin -= 360F;
}
}
}
@Override
public void networkUnpack(NBTTagCompound nbt) {
this.heat = nbt.getInteger("heat");
this.progress = nbt.getInteger("progress");
this.hasBlade = nbt.getBoolean("hasBlade");
NBTTagList list = nbt.getTagList("items", 10);
slots = new ItemStack[3];
for(int i = 0; i < list.tagCount(); i++) {
NBTTagCompound nbt1 = list.getCompoundTagAt(i);
byte b0 = nbt1.getByte("slot");
if(b0 >= 0 && b0 < slots.length) {
slots[b0] = ItemStack.loadItemStackFromNBT(nbt1);
}
}
}
protected void tryPullHeat() {
TileEntity con = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord);
if(con instanceof IHeatSource) {
IHeatSource source = (IHeatSource) con;
int heatSrc = (int) (source.getHeatStored() * diffusion);
if(heatSrc > 0) {
source.useUpHeat(heatSrc);
this.heat += heatSrc;
return;
}
}
this.heat = Math.max(this.heat - Math.max(this.heat / 1000, 1), 0);
}
protected InventoryCraftingAuto craftingInventory = new InventoryCraftingAuto(1, 1);
@Override
public boolean isItemValidForSlot(int i, ItemStack stack) {
return i == 0 && slots[0] == null && slots[1] == null && slots[2] == null && stack.stackSize == 1 && getOutput(stack) != null;
}
@Override
public boolean canExtractItem(int i, ItemStack itemStack, int j) {
return i > 0;
}
@Override
public int[] getAccessibleSlotsFromSide(int side) {
return new int[] {0, 1, 2};
}
public ItemStack getOutput(ItemStack input) {
if(input == null)
return null;
craftingInventory.setInventorySlotContents(0, input);
List<String> names = ItemStackUtil.getOreDictNames(input);
if(names.contains("logWood")) {
for(Object o : CraftingManager.getInstance().getRecipeList()) {
IRecipe recipe = (IRecipe) o;
if(recipe.matches(craftingInventory, worldObj)) {
ItemStack out = recipe.getCraftingResult(craftingInventory);
if(out != null) {
out = out.copy(); //for good measure
out.stackSize = out.stackSize * 6 / 4; //4 planks become 6
return out;
}
}
}
}
if(names.contains("plankWood")) {
return new ItemStack(Items.stick, 4);
}
return null;
}
AxisAlignedBB bb = null;
@Override
public AxisAlignedBB getRenderBoundingBox() {
if(bb == null) {
bb = AxisAlignedBB.getBoundingBox(
xCoord - 1,
yCoord,
zCoord - 1,
xCoord + 2,
yCoord + 2,
zCoord + 2
);
}
return bb;
}
@Override
@SideOnly(Side.CLIENT)
public double getMaxRenderDistanceSquared() {
return 65536.0D;
}
}

View File

@ -139,22 +139,12 @@ public class ItemStackUtil {
return stacks;
}
//private static HashMap<ComparableStack, List<String>> buffered = new HashMap();
/**
* Returns a List<String> of all ore dict names for this stack. Stack cannot be null, list is empty when there are no ore dict entries.
* @param stack
* @return
*/
public static List<String> getOreDictNames(ItemStack stack) {
/*ÜComparableStack comp = new ComparableStack(stack).makeSingular();
List<String> buff = buffered.get(comp);
if(buff != null)
return buff;*/
List<String> list = new ArrayList();
int ids[] = OreDictionary.getOreIDs(stack);
@ -162,7 +152,6 @@ public class ItemStackUtil {
list.add(OreDictionary.getOreName(i));
}
//buffered.put(comp, new ArrayList(list));
return list;
}
}

View File

@ -3496,6 +3496,7 @@ tile.machine_rtg_purple.name=Paarvernichtungsgenerator
tile.machine_rtg_red.name=Fulminationsgenerator
tile.machine_rtg_yellow.name=Australium Supergenerator
tile.machine_satlinker.name=Satelliten-ID-Manager
tile.machine_sawmill.name=Stirling-Sägemühle
tile.machine_schrabidium_battery.name=Schrabidium-Energiespeicherblock
tile.machine_schrabidium_transmutator.name=Schrabidium-Transmutationsgerät
tile.machine_selenium.name=Hochleistungs-Sternmotor

View File

@ -3936,6 +3936,7 @@ tile.machine_rtg_purple.name=Antimatter Annihilation Generator
tile.machine_rtg_red.name=Fulmination Generator
tile.machine_rtg_yellow.name=Australium Superfuel Reactor
tile.machine_satlinker.name=Satellite ID Manager
tile.machine_sawmill.name=Stirling Sawmill
tile.machine_schrabidium_battery.name=Schrabidium Energy Storage Block
tile.machine_schrabidium_transmutator.name=Schrabidium Transmutation Device
tile.machine_selenium.name=Radial Performance Engine

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB