mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
fixed potential liquefactor NPE, cursed vanilla code
This commit is contained in:
parent
f4a2d72e5a
commit
b1c5c23615
@ -1,62 +1,73 @@
|
||||
package com.hbm.entity.mob.siege;
|
||||
|
||||
import com.hbm.entity.mob.EntityBurrowingBase;
|
||||
import com.hbm.entity.mob.EntityBurrowingSwingingBase;
|
||||
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.IEntityLivingData;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.EntityAISwimming;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.monster.EntityMob;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntitySiegeTunneler extends EntityBurrowingBase {
|
||||
//cursed code ahead
|
||||
//no, this time it's vanilla that is cursed
|
||||
//for NO FUCKING REASON IN PARTICULAR, EntityCreatue mobs aren't synchronized to clients AT ALL
|
||||
//yet EntityMob that inherits EntityCreature and adds ABSOLUTELY FUCKING NOTHING other than base functionality works
|
||||
//why?
|
||||
//is that some sort of elaborate prank i'm not smart enough to understand?
|
||||
//well it ain't fucking funny
|
||||
//this stupid fucking random ass bullshit is the P R E C I S E reason i loathe working with entities
|
||||
//honest to fucking god was the entire mojang dev team on crack when they wrote this?
|
||||
public class EntitySiegeTunneler extends EntityMob {
|
||||
|
||||
public EntitySiegeTunneler(World world) {
|
||||
super(world);
|
||||
this.tasks.addTask(0, new EntityAISwimming(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
super.entityInit();
|
||||
this.getDataWatcher().addObject(12, (int) 0);
|
||||
//this.getDataWatcher().addObject(12, (int) 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyEntityAttributes() {
|
||||
super.applyEntityAttributes();
|
||||
this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D);
|
||||
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.23D);
|
||||
//this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D);
|
||||
//this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.23D);
|
||||
}
|
||||
|
||||
public void setTier(SiegeTier tier) {
|
||||
this.getDataWatcher().updateObject(12, tier.id);
|
||||
//this.getDataWatcher().updateObject(12, tier.id);
|
||||
|
||||
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).applyModifier(new AttributeModifier("Tier Speed Mod", tier.speedMod, 1));
|
||||
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(tier.health);
|
||||
this.setHealth(this.getMaxHealth());
|
||||
//this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).applyModifier(new AttributeModifier("Tier Speed Mod", tier.speedMod, 1));
|
||||
//this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(tier.health);
|
||||
//this.setHealth(this.getMaxHealth());
|
||||
}
|
||||
|
||||
public SiegeTier getTier() {
|
||||
SiegeTier tier = SiegeTier.tiers[this.getDataWatcher().getWatchableObjectInt(12)];
|
||||
return tier != null ? tier : SiegeTier.CLAY;
|
||||
//SiegeTier tier = SiegeTier.tiers[this.getDataWatcher().getWatchableObjectInt(12)];
|
||||
return /*tier != null ? tier :*/ SiegeTier.CLAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
super.writeEntityToNBT(nbt);
|
||||
nbt.setInteger("siegeTier", this.getTier().id);
|
||||
//nbt.setInteger("siegeTier", this.getTier().id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
super.readEntityFromNBT(nbt);
|
||||
this.setTier(SiegeTier.tiers[nbt.getInteger("siegeTier")]);
|
||||
//this.setTier(SiegeTier.tiers[nbt.getInteger("siegeTier")]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) {
|
||||
this.setTier(SiegeTier.tiers[rand.nextInt(SiegeTier.getLength())]);
|
||||
this.addRandomArmor();
|
||||
//this.setTier(SiegeTier.tiers[rand.nextInt(SiegeTier.getLength())]);
|
||||
return super.onSpawnWithEgg(data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,10 +27,13 @@ public class GUIHandler implements IGuiHandler {
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity entity = world.getTileEntity(x, y, z);
|
||||
|
||||
|
||||
if(entity instanceof TileEntityMachineLiquefactor) {
|
||||
return new ContainerLiquefactor(player.inventory, (TileEntityMachineLiquefactor) entity);
|
||||
}
|
||||
if(entity instanceof TileEntityMachineSolidifier) {
|
||||
return new ContainerSolidifier(player.inventory, (TileEntityMachineSolidifier) entity);
|
||||
}
|
||||
|
||||
switch(ID) {
|
||||
case ModBlocks.guiID_test_difurnace: {
|
||||
|
||||
@ -0,0 +1,71 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.inventory.SlotUpgrade;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineSolidifier;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerSolidifier extends Container {
|
||||
|
||||
private TileEntityMachineSolidifier solidifier;
|
||||
|
||||
public ContainerSolidifier(InventoryPlayer playerInv, TileEntityMachineSolidifier tile) {
|
||||
solidifier = tile;
|
||||
|
||||
//Input
|
||||
this.addSlotToContainer(new Slot(tile, 0, 71, 45));
|
||||
//Battery
|
||||
this.addSlotToContainer(new Slot(tile, 1, 134, 72));
|
||||
//Upgrades
|
||||
this.addSlotToContainer(new SlotUpgrade(tile, 2, 98, 36));
|
||||
this.addSlotToContainer(new SlotUpgrade(tile, 3, 98, 54));
|
||||
//ID
|
||||
this.addSlotToContainer(new Slot(tile, 4, 71, 72));
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 9; j++) {
|
||||
this.addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 122 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
this.addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 180));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return solidifier.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
||||
ItemStack var3 = null;
|
||||
Slot var4 = (Slot) this.inventorySlots.get(index);
|
||||
|
||||
if(var4 != null && var4.getHasStack()) {
|
||||
ItemStack var5 = var4.getStack();
|
||||
var3 = var5.copy();
|
||||
|
||||
if(index <= 2) {
|
||||
if(!this.mergeItemStack(var5, 5, this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
} else if(!this.mergeItemStack(var5, 0, 4, false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(var5.stackSize == 0) {
|
||||
var4.putStack((ItemStack) null);
|
||||
} else {
|
||||
var4.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
}
|
||||
@ -88,6 +88,9 @@ public class TileEntityMachineLiquefactor extends TileEntityMachineBase implemen
|
||||
|
||||
FluidStack out = LiquefactionRecipes.getOutput(slots[0]);
|
||||
|
||||
if(out == null)
|
||||
return false;
|
||||
|
||||
if(out.type != tank.getTankType() && tank.getFill() > 0)
|
||||
return false;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user