Skip to content

Commit

Permalink
conveyor destroyer mode
Browse files Browse the repository at this point in the history
  • Loading branch information
HbmMods committed Sep 8, 2024
1 parent 59d5494 commit 7f91038
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 10 deletions.
2 changes: 2 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Updated CMB brick texture
* The ICF machine block now renders with its 3d model in the creative inventory
* "Toggle backpack" keybind is now called "toggle jetpack" to reduce confusion
* The xenium resonator can now teleport players using the radar linker
* Inserters now have a toggleable destroyer mode which will delete items that cannot be inserted or cached instead of spilling them

## Fixed
* Fixed pumpjack gauges not syncing properly
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod_version=1.0.27
# Empty build number makes a release type
mod_build_number=5061
mod_build_number=5082

credits=HbMinecraft,\
\ rodolphito (explosion algorithms),\
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/hbm/blocks/network/CraneInserter.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ public void onItemEnter(World world, int x, int y, int z, ForgeDirection dir, IC
addToInventory(inv, access, toAdd, outputDirection.getOpposite().ordinal());
}

TileEntityCraneInserter inserter = null;

if(toAdd.stackSize > 0) {
addToInventory((TileEntityCraneInserter) world.getTileEntity(x, y, z), null, toAdd, outputDirection.getOpposite().ordinal());
inserter = (TileEntityCraneInserter) world.getTileEntity(x, y, z);
addToInventory(inserter, null, toAdd, outputDirection.getOpposite().ordinal());
}
if(toAdd.stackSize > 0) {
if(toAdd.stackSize > 0 && inserter != null && !inserter.destroyer) {
EntityItem drop = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, toAdd.copy());
world.spawnEntityInWorld(drop);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public ContainerCraneInserter(InventoryPlayer invPlayer, TileEntityCraneInserter

for(int i = 0; i < 3; i++) {
for(int j = 0; j < 7; j++) {
this.addSlotToContainer(new Slot(inserter, j + i * 7, 26 + j * 18, 17 + i * 18));
this.addSlotToContainer(new Slot(inserter, j + i * 7, 8 + j * 18, 17 + i * 18));
}
}

Expand Down
21 changes: 20 additions & 1 deletion src/main/java/com/hbm/inventory/gui/GUICraneInserter.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@

import com.hbm.inventory.container.ContainerCraneInserter;
import com.hbm.lib.RefStrings;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toserver.NBTControlPacket;
import com.hbm.tileentity.network.TileEntityCraneInserter;

import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;

public class GUICraneInserter extends GuiInfoContainer {
Expand All @@ -23,11 +27,23 @@ public GUICraneInserter(InventoryPlayer invPlayer, TileEntityCraneInserter tedf)
this.xSize = 176;
this.ySize = 185;
}

@Override
protected void mouseClicked(int x, int y, int i) {
super.mouseClicked(x, y, i);

if(guiLeft + 151 <= x && guiLeft + 151 + 18 > x && guiTop + 34 < y && guiTop + 34 + 18 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
NBTTagCompound data = new NBTTagCompound();
data.setBoolean("destroyer", true);
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, inserter.xCoord, inserter.yCoord, inserter.zCoord));
}
}

@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {
String name = this.inserter.hasCustomInventoryName() ? this.inserter.getInventoryName() : I18n.format(this.inserter.getInventoryName());
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2 - 18, 5, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}

Expand All @@ -36,5 +52,8 @@ protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);

if(inserter.destroyer)
drawTexturedModalRect(guiLeft + 151, guiTop + 34, 176, 0, 18, 18);
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/hbm/items/tool/ItemDiscord.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla

MovingObjectPosition pos = Library.rayTrace(player, 100, 1);

if(pos.typeOfHit == MovingObjectType.BLOCK) {
if(pos != null && pos.typeOfHit == MovingObjectType.BLOCK) {

if(!world.isRemote) {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/hbm/lib/RefStrings.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class RefStrings {
public static final String MODID = "hbm";
public static final String NAME = "Hbm's Nuclear Tech Mod";
public static final String VERSION = "1.0.27 BETA (5061)";
public static final String VERSION = "1.0.27 BETA (5082)";
//HBM's Beta Naming Convention:
//V T (X)
//V -> next release version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import api.hbm.conveyor.IConveyorBelt;
import com.hbm.entity.item.EntityMovingItem;
import com.hbm.interfaces.IControlReceiver;
import com.hbm.inventory.container.ContainerCraneExtractor;
import com.hbm.inventory.gui.GUICraneExtractor;
import com.hbm.items.ModItems;
Expand All @@ -26,7 +25,7 @@
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;

public class TileEntityCraneExtractor extends TileEntityCraneBase implements IGUIProvider, IControlReceiver, IControlReceiverFilter {
public class TileEntityCraneExtractor extends TileEntityCraneBase implements IGUIProvider, IControlReceiverFilter {

public boolean isWhitelist = false;
public ModulePatternMatcher matcher;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
package com.hbm.tileentity.network;

import com.hbm.blocks.network.CraneInserter;
import com.hbm.interfaces.IControlReceiver;
import com.hbm.inventory.container.ContainerCraneInserter;
import com.hbm.inventory.gui.GUICraneInserter;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.util.InventoryUtil;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;

public class TileEntityCraneInserter extends TileEntityCraneBase implements IGUIProvider {
public class TileEntityCraneInserter extends TileEntityCraneBase implements IGUIProvider, IControlReceiver {

public boolean destroyer = true;
public static final int[] access = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };

public TileEntityCraneInserter() {
Expand Down Expand Up @@ -82,9 +87,23 @@ public void updateEntity() {
}
}
}

this.networkPackNT(15);
}
}

@Override
public void serialize(ByteBuf buf) {
super.serialize(buf);
buf.writeBoolean(destroyer);
}

@Override
public void deserialize(ByteBuf buf) {
super.deserialize(buf);
destroyer = buf.readBoolean();
}

@Override
public int[] getAccessibleSlotsFromSide(int side) {
return access;
Expand All @@ -110,4 +129,26 @@ public Container provideContainer(int ID, EntityPlayer player, World world, int
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new GUICraneInserter(player.inventory, this);
}

@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.destroyer = nbt.getBoolean("destroyer");
}

@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setBoolean("destroyer", this.destroyer);
}

@Override
public boolean hasPermission(EntityPlayer player) {
return Vec3.createVectorHelper(xCoord - player.posX, yCoord - player.posY, zCoord - player.posZ).lengthVector() < 20;
}

@Override
public void receiveControl(NBTTagCompound data) {
if(data.hasKey("destroyer")) this.destroyer = !this.destroyer;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7f91038

Please sign in to comment.