From cd319ef44d1732a565ad02e683b87afd7805f554 Mon Sep 17 00:00:00 2001 From: Boblet Date: Tue, 28 Mar 2023 16:54:15 +0200 Subject: [PATCH] experimental particle crap, watz item IO --- src/main/java/com/hbm/main/ClientProxy.java | 2 + .../engine/EventHandlerParticleEngine.java | 32 ++++++++++ .../com/hbm/particle/psys/engine/PSysFX.java | 32 ++++++++++ .../particle/psys/engine/ParticleEngine.java | 58 +++++++++++++++++++ .../tileentity/machine/TileEntityWatz.java | 39 ++++++++++++- 5 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/hbm/particle/psys/engine/EventHandlerParticleEngine.java create mode 100644 src/main/java/com/hbm/particle/psys/engine/PSysFX.java create mode 100644 src/main/java/com/hbm/particle/psys/engine/ParticleEngine.java diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index 4e375b168..d58e6c015 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -65,6 +65,7 @@ import com.hbm.handler.ImpactWorldHandler; import com.hbm.handler.HbmKeybinds.EnumKeybind; import com.hbm.items.ModItems; import com.hbm.particle.*; +import com.hbm.particle.psys.engine.EventHandlerParticleEngine; import com.hbm.render.anim.*; import com.hbm.render.anim.HbmAnimations.Animation; import com.hbm.render.block.*; @@ -115,6 +116,7 @@ public class ClientProxy extends ServerProxy { registerClientEventHandler(new ModEventHandlerClient()); registerClientEventHandler(new ModEventHandlerRenderer()); + registerClientEventHandler(new EventHandlerParticleEngine()); registerClientEventHandler(theInfoSystem); AdvancedModelLoader.registerModelHandler(new HmfModelLoader()); diff --git a/src/main/java/com/hbm/particle/psys/engine/EventHandlerParticleEngine.java b/src/main/java/com/hbm/particle/psys/engine/EventHandlerParticleEngine.java new file mode 100644 index 000000000..17c189f19 --- /dev/null +++ b/src/main/java/com/hbm/particle/psys/engine/EventHandlerParticleEngine.java @@ -0,0 +1,32 @@ +package com.hbm.particle.psys.engine; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.event.world.WorldEvent; + +@SideOnly(Side.CLIENT) +public class EventHandlerParticleEngine { + + @SubscribeEvent + public void worldTick(WorldTickEvent event) { + + if(event.phase == event.phase.START) { + + } + } + + @SubscribeEvent + public void onRenderWorldLast(RenderWorldLastEvent event) { + float interp = event.partialTicks; + } + + @SubscribeEvent + public void onWorldLoad(WorldEvent.Load event) { + /* create new engine instance on every new world load (when joining servers, switching dimensions, etc), prevents particles from persisting between worlds */ + ParticleEngine.INSTANCE = new ParticleEngine(event.world, Minecraft.getMinecraft().renderEngine); + } +} diff --git a/src/main/java/com/hbm/particle/psys/engine/PSysFX.java b/src/main/java/com/hbm/particle/psys/engine/PSysFX.java new file mode 100644 index 000000000..4abb6412c --- /dev/null +++ b/src/main/java/com/hbm/particle/psys/engine/PSysFX.java @@ -0,0 +1,32 @@ +package com.hbm.particle.psys.engine; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.world.World; + +/** + * HBM: reinventing the fucking wheel for the 15th time since 2014 + * + * @author hbm + */ +@SideOnly(Side.CLIENT) +public class PSysFX { + + public World world; + public double posX; + public double posY; + public double posZ; + public double prevPosX; + public double prevPosY; + public double prevPosZ; + public double motionX; + public double motionY; + public double motionZ; + public static double interpPosX; + public static double interpPosY; + public static double interpPosZ; + + public PSysFX() { + + } +} diff --git a/src/main/java/com/hbm/particle/psys/engine/ParticleEngine.java b/src/main/java/com/hbm/particle/psys/engine/ParticleEngine.java new file mode 100644 index 000000000..6c46b7b19 --- /dev/null +++ b/src/main/java/com/hbm/particle/psys/engine/ParticleEngine.java @@ -0,0 +1,58 @@ +package com.hbm.particle.psys.engine; + +import java.util.List; +import java.util.Random; + +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +public class ParticleEngine { + + public static ParticleEngine INSTANCE; + + public World world; + public TextureManager texman; + public FXLayer[] layers; + protected Random rand = new Random(); + + public ParticleEngine(World world, TextureManager texman) { + this.world = world; + this.texman = texman; + setupLayers(); + } + + private void setupLayers() { + layers = new FXLayer[] { + + }; + } + + public void updateParticles() { + + } + + public void renderParticles(float interp) { + + } + + public static class FXLayer { + + protected ResourceLocation batchTexture; + protected List particles; + + public FXLayer() { } + + public FXLayer(ResourceLocation batchTexture) { + this.batchTexture = batchTexture; + } + + protected void updateLayer() { + + } + + protected void renderLayer() { + + } + } +} diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityWatz.java b/src/main/java/com/hbm/tileentity/machine/TileEntityWatz.java index fe4c48a0e..f5e8f68de 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityWatz.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityWatz.java @@ -3,6 +3,7 @@ package com.hbm.tileentity.machine; import java.util.ArrayList; import java.util.List; +import com.hbm.interfaces.IControlReceiver; import com.hbm.inventory.container.ContainerWatz; import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.tank.FluidTank; @@ -32,7 +33,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityWatz extends TileEntityMachineBase implements IFluidStandardTransceiver, IGUIProvider { +public class TileEntityWatz extends TileEntityMachineBase implements IFluidStandardTransceiver, IControlReceiver, IGUIProvider { public FluidTank[] tanks; public int heat; @@ -42,10 +43,11 @@ public class TileEntityWatz extends TileEntityMachineBase implements IFluidStand /* lock types for item IO */ public boolean isLocked = false; - public ItemStack[] locks = new ItemStack[24]; + public ItemStack[] locks; public TileEntityWatz() { super(24); + this.locks = new ItemStack[slots.length]; this.tanks = new FluidTank[3]; this.tanks[0] = new FluidTank(Fluids.COOLANT, 64_000); this.tanks[1] = new FluidTank(Fluids.COOLANT_HOT, 64_000); @@ -280,10 +282,43 @@ public class TileEntityWatz extends TileEntityMachineBase implements IFluidStand } } + @Override + public boolean hasPermission(EntityPlayer player) { + return this.isUseableByPlayer(player); + } + + @Override + public void receiveControl(NBTTagCompound data) { + + if(data.hasKey("lock")) { + + if(this.isLocked) { + this.locks = new ItemStack[slots.length]; + } else { + for(int i = 0; i < slots.length; i++) { + this.locks[i] = slots[i]; + } + } + + this.isLocked = !this.isLocked; + this.markChanged(); + } + } + @Override public boolean isItemValidForSlot(int i, ItemStack stack) { return stack.getItem() == ModItems.watz_pellet; } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}; + } + + @Override + public boolean canExtractItem(int i, ItemStack stack, int j) { + return stack.getItem() != ModItems.watz_pellet; + } @Override public int getInventoryStackLimit() {