lasers, pew pew

This commit is contained in:
Boblet 2024-05-03 14:48:17 +02:00
parent b72b66a083
commit 810038bb60
25 changed files with 120 additions and 8 deletions

View File

@ -1,9 +1,12 @@
package com.hbm.blocks.machine;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.machine.BlockICF.TileEntityBlockICF;
import com.hbm.blocks.machine.BlockICFLaserComponent.EnumICFPart;
@ -11,6 +14,8 @@ import com.hbm.lib.RefStrings;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import com.hbm.tileentity.machine.TileEntityICFController;
import com.hbm.util.BobMathUtil;
import com.hbm.util.I18nUtil;
import com.hbm.util.fauxpointtwelve.BlockPos;
import cpw.mods.fml.relauncher.Side;
@ -28,9 +33,10 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
import net.minecraftforge.common.util.ForgeDirection;
public class MachineICFController extends BlockContainer {
public class MachineICFController extends BlockContainer implements ILookOverlay {
@SideOnly(Side.CLIENT)
private IIcon iconFront;
@ -207,4 +213,14 @@ public class MachineICFController extends BlockContainer {
PacketDispatcher.wrapper.sendTo(new AuxParticlePacketNT(data, x, y, z), (EntityPlayerMP) player);
}
}
@Override
public void printHook(Pre event, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileEntityICFController)) return;
TileEntityICFController icf = (TileEntityICFController) te;
List<String> text = new ArrayList();
text.add(BobMathUtil.getShortNumber(icf.getPower()) + "/" + BobMathUtil.getShortNumber(icf.getMaxPower()) + "HE");
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
}
}

View File

@ -1,13 +1,15 @@
package com.hbm.tileentity;
import com.hbm.packet.BufPacket;
import com.hbm.packet.NBTPacket;
import com.hbm.packet.PacketDispatcher;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidTank;
public abstract class TileEntityTickingBase extends TileEntityLoadedBase implements INBTPacketReceiver {
public abstract class TileEntityTickingBase extends TileEntityLoadedBase implements INBTPacketReceiver, IBufPacketReceiver {
public TileEntityTickingBase() { }
@ -22,16 +24,28 @@ public abstract class TileEntityTickingBase extends TileEntityLoadedBase impleme
//was it update? onUpdate? updateTile? did it have any args?
//shit i don't know man
@Override
public abstract void updateEntity();
public abstract void updateEntity();
public void networkPack(NBTTagCompound nbt, int range) {
@Deprecated public void networkPack(NBTTagCompound nbt, int range) {
if(!worldObj.isRemote)
PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
}
public void networkUnpack(NBTTagCompound nbt) { }
@Deprecated public void networkUnpack(NBTTagCompound nbt) { }
@Deprecated
public void handleButtonPacket(int value, int meta) { }
public void networkPackNT(int range) {
if(!worldObj.isRemote) PacketDispatcher.wrapper.sendToAllAround(new BufPacket(xCoord, yCoord, zCoord, this), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
}
@Override public void serialize(ByteBuf buf) {
buf.writeBoolean(muffled);
}
@Override public void deserialize(ByteBuf buf) {
this.muffled = buf.readBoolean();
}
}

View File

@ -13,6 +13,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
@ -43,6 +44,23 @@ public class TileEntityICF extends TileEntityMachineBase implements IGUIProvider
}
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack) {
return slot < 5;
}
@Override
public boolean canExtractItem(int slot, ItemStack stack, int side) {
return slot > 5;
}
public static final int[] io = new int[] {0, 1, 2, 3, 4, 6, 7, 8, 9, 10};
@Override
public int[] getAccessibleSlotsFromSide(int side) {
return io;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
if(worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) {

View File

@ -8,6 +8,8 @@ import com.hbm.tileentity.TileEntityTickingBase;
import com.hbm.util.fauxpointtwelve.BlockPos;
import api.hbm.energymk2.IEnergyReceiverMK2;
import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityICFController extends TileEntityTickingBase implements IEnergyReceiverMK2 {
@ -51,13 +53,13 @@ public class TileEntityICFController extends TileEntityTickingBase implements IE
for(BlockPos capacitor : capacitors) { for(ForgeDirection offset : ForgeDirection.VALID_DIRECTIONS) {
pos.mutate(capacitor.getX() + offset.offsetX, capacitor.getY() + offset.offsetY, capacitor.getZ() + offset.offsetZ);
if(emitters.contains(pos)) { this.emitterCount++; break; }
if(emitters.contains(pos)) { this.capacitorCount++; break; }
}
}
for(BlockPos turbo : turbochargers) { for(ForgeDirection offset : ForgeDirection.VALID_DIRECTIONS) {
pos.mutate(turbo.getX() + offset.offsetX, turbo.getY() + offset.offsetY, turbo.getZ() + offset.offsetZ);
if(capacitors.contains(pos)) { this.emitterCount++; break; }
if(capacitors.contains(pos)) { this.turbochargerCount++; break; }
}
}
@ -72,11 +74,73 @@ public class TileEntityICFController extends TileEntityTickingBase implements IE
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
if(this.assembled) {
for(BlockPos pos : ports) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
BlockPos portPos = pos.offset(dir);
if(this.getMaxPower() > 0) this.trySubscribe(worldObj, portPos.getX(), portPos.getY(), portPos.getZ(), dir);
}
}
}
this.networkPackNT(50);
}
}
@Override public void serialize(ByteBuf buf) {
super.serialize(buf);
buf.writeLong(power);
buf.writeInt(capacitorCount);
buf.writeInt(turbochargerCount);
}
@Override public void deserialize(ByteBuf buf) {
super.deserialize(buf);
this.power = buf.readLong();
this.capacitorCount = buf.readInt();
this.turbochargerCount = buf.readInt();
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.assembled = nbt.getBoolean("assembled");
this.cellCount = nbt.getInteger("cellCount");
this.emitterCount = nbt.getInteger("emitterCount");
this.capacitorCount = nbt.getInteger("capacitorCount");
this.turbochargerCount = nbt.getInteger("turbochargerCount");
ports.clear();
int portCount = nbt.getInteger("portCount");
for(int i = 0; i < portCount; i++) {
int[] port = nbt.getIntArray("p" + i);
ports.add(new BlockPos(port[0], port[1], port[2]));
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setBoolean("assembled", assembled);
nbt.setInteger("cellCount", cellCount);
nbt.setInteger("emitterCount", emitterCount);
nbt.setInteger("capacitorCount", capacitorCount);
nbt.setInteger("turbochargerCount", turbochargerCount);
nbt.setInteger("portCount", ports.size());
for(int i = 0; i < ports.size(); i++) {
BlockPos pos = ports.get(i);
nbt.setIntArray("p" + i, new int[] { pos.getX(), pos.getY(), pos.getZ() });
}
}
@Override
public long getPower() {
return power;
return Math.min(power, this.getMaxPower());
}
@Override

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B