custom falling block, mojang stink

This commit is contained in:
Boblet 2023-09-22 15:24:23 +02:00
parent b1dd140737
commit bb591306db
13 changed files with 501 additions and 43 deletions

View File

@ -0,0 +1,96 @@
package com.hbm.blocks;
import java.util.Random;
import com.hbm.entity.item.EntityFallingBlockNT;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
public class BlockFallingNT extends Block {
public static boolean fallInstantly;
public BlockFallingNT() {
super(Material.sand);
this.setCreativeTab(CreativeTabs.tabBlock);
}
public BlockFallingNT(Material mat) {
super(mat);
}
@Override
public void onBlockAdded(World world, int x, int y, int z) {
world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world));
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world));
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
if(!world.isRemote) {
this.fall(world, x, y, z);
}
}
protected void fall(World world, int x, int y, int z) {
if(canFallThrough(world, x, y - 1, z) && y >= 0) {
byte range = 32;
if(!fallInstantly && world.checkChunksExist(x - range, y - range, z - range, x + range, y + range, z + range)) {
if(!world.isRemote) {
EntityFallingBlockNT entityfallingblock = new EntityFallingBlockNT(world, x + 0.5D, y + 0.5D, z + 0.5D, this, world.getBlockMetadata(x, y, z));
this.modifyFallingBlock(entityfallingblock);
world.spawnEntityInWorld(entityfallingblock);
}
} else {
world.setBlockToAir(x, y, z);
while(canFallThrough(world, x, y - 1, z) && y > 0) {
--y;
}
if(y > 0) {
world.setBlock(x, y, z, this);
}
}
}
}
protected void modifyFallingBlock(EntityFallingBlockNT falling) { }
@Override
public int tickRate(World world) {
return 2;
}
public static boolean canFallThrough(World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
if(block.isAir(world, x, y, z)) {
return true;
} else if(block == Blocks.fire) {
return true;
} else {
Material material = block.getMaterial();
return material == Material.water ? true : material == Material.lava;
}
}
public void onLand(World world, int x, int y, int z, int meta) { }
@SideOnly(Side.CLIENT) public boolean shouldOverrideRenderer() { return false; }
@SideOnly(Side.CLIENT) public void overrideRenderer(EntityFallingBlockNT falling, RenderBlocks renderBlocks, Tessellator tessellator) { }
}

View File

@ -4,12 +4,16 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.hbm.blocks.BlockFallingNT;
import com.hbm.blocks.ITooltipProvider;
import com.hbm.blocks.ModBlocks;
import com.hbm.entity.item.EntityFallingBlockNT;
import com.hbm.inventory.container.ContainerAnvil;
import com.hbm.inventory.gui.GUIAnvil;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.main.ResourceManager;
import com.hbm.render.util.ObjUtil;
import com.hbm.tileentity.IGUIProvider;
import cpw.mods.fml.client.registry.RenderingRegistry;
@ -17,9 +21,10 @@ import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFalling;
import net.minecraft.block.material.Material;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@ -31,8 +36,9 @@ import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.model.obj.WavefrontObject;
public class NTMAnvil extends BlockFalling implements ITooltipProvider, IGUIProvider {
public class NTMAnvil extends BlockFallingNT implements ITooltipProvider, IGUIProvider {
public final int tier;
@ -180,4 +186,36 @@ public class NTMAnvil extends BlockFalling implements ITooltipProvider, IGUIProv
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new GUIAnvil(player.inventory, ((NTMAnvil)world.getBlock(x, y, z)).tier);
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldOverrideRenderer() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void overrideRenderer(EntityFallingBlockNT falling, RenderBlocks renderBlocks, Tessellator tessellator) {
World world = falling.worldObj;
float rotation = 0;
if(falling.getMeta() == 2)
rotation = 90F / 180F * (float) Math.PI;
if(falling.getMeta() == 3)
rotation = 270F / 180F * (float) Math.PI;
if(falling.getMeta() == 4)
rotation = 180F / 180F * (float)Math.PI;
tessellator.addTranslation(0F, -0.5F, 0F);
ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.anvil, "Top", getIcon(1, 0), tessellator, rotation, true);
ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.anvil, "Bottom", getIcon(0, 0), tessellator, rotation, true);
ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.anvil, "Front", getIcon(0, 0), tessellator, rotation, true);
ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.anvil, "Back", getIcon(0, 0), tessellator, rotation, true);
ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.anvil, "Left", getIcon(0, 0), tessellator, rotation, true);
ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.anvil, "Right", getIcon(0, 0), tessellator, rotation, true);
tessellator.addTranslation(0F, 0.5F, 0F);
}
}

View File

@ -14,13 +14,8 @@ import com.hbm.tileentity.network.TileEntityCableBaseNT;
import com.hbm.util.BobMathUtil;
import com.hbm.util.I18nUtil;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import li.cil.oc.api.network.SimpleComponent;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.material.Material;
@ -103,8 +98,7 @@ public class BlockCableGauge extends BlockContainer implements IBlockMultiPass,
return IBlockMultiPass.getRenderType();
}
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
public static class TileEntityCableGauge extends TileEntityCableBaseNT implements INBTPacketReceiver, SimpleComponent {
public static class TileEntityCableGauge extends TileEntityCableBaseNT implements INBTPacketReceiver {
private BigInteger lastMeasurement = BigInteger.valueOf(10);
private long deltaTick = 0;
@ -145,21 +139,5 @@ public class BlockCableGauge extends BlockContainer implements IBlockMultiPass,
this.deltaTick = Math.max(nbt.getLong("deltaT"), 0);
this.deltaLastSecond = Math.max(nbt.getLong("deltaS"), 0);
}
public String getComponentName() {
return "ntm_cable_gauge";
}
@Callback(direct = true, limit = 8)
@Optional.Method(modid = "OpenComputers")
public Object[] getTransfer(Context context, Arguments args) {
return new Object[] {deltaTick, deltaSecond};
}
@Callback(direct = true, limit = 8)
@Optional.Method(modid = "OpenComputers")
public Object[] getInfo(Context context, Arguments args) {
return new Object[] {deltaTick, deltaSecond, xCoord, yCoord, zCoord};
}
}
}

View File

@ -213,6 +213,7 @@ public class EntityMappings {
addEntity(EntityChemical.class, "entity_chemthrower_splash", 1000);
addEntity(EntityMist.class, "entity_mist", 250, false);
addEntity(EntityAcidBomb.class, "entity_acid_bomb", 1000);
addEntity(EntityFallingBlockNT.class, "entity_falling_block_nt", 1000);
addEntity(EntityItemWaste.class, "entity_item_waste", 100);
addEntity(EntityItemBuoyant.class, "entity_item_buoyant", 100);

View File

@ -4,12 +4,12 @@ import com.hbm.blocks.ModBlocks;
import com.hbm.config.BombConfig;
import com.hbm.config.FalloutConfigJSON;
import com.hbm.config.FalloutConfigJSON.FalloutEntry;
import com.hbm.entity.item.EntityFallingBlockNT;
import com.hbm.saveddata.AuxSavedData;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
@ -178,8 +178,8 @@ public class EntityFalloutRain extends Entity {
for(int i = 0; i <= depth; i++) {
hardness = worldObj.getBlock(x, y + i, z).getBlockHardness(worldObj, x, y + i, z);
if(hardness <= Blocks.stonebrick.getExplosionResistance(null) && hardness >= 0) {
EntityFallingBlock entityfallingblock = new EntityFallingBlock(worldObj, x + 0.5D, y + 0.5D + i, z + 0.5D, worldObj.getBlock(x, y + i, z), worldObj.getBlockMetadata(x, y + i, z));
entityfallingblock.field_145813_c = false; //turn off block drops because block dropping was coded by a mule with dementia
EntityFallingBlockNT entityfallingblock = new EntityFallingBlockNT(worldObj, x + 0.5D, y + 0.5D + i, z + 0.5D, worldObj.getBlock(x, y + i, z), worldObj.getBlockMetadata(x, y + i, z));
entityfallingblock.canDrop = false; //turn off block drops because block dropping was coded by a mule with dementia
worldObj.spawnEntityInWorld(entityfallingblock);
}
}

View File

@ -0,0 +1,286 @@
package com.hbm.entity.item;
import java.util.ArrayList;
import java.util.Iterator;
import com.hbm.blocks.BlockFallingNT;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFalling;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class EntityFallingBlockNT extends Entity {
private Block fallingBlock;
public int fallingMeta = -1;
public int fallingTicks;
public boolean canDrop;
private boolean destroyOnLand;
private boolean canHurtEntities;
private int damageCap;
private float damageAmount;
public NBTTagCompound tileNBT;
public EntityFallingBlockNT(World world) {
super(world);
this.canDrop = true;
this.damageCap = 40;
this.damageAmount = 2.0F;
this.setSize(0.98F, 0.98F);
this.yOffset = this.height / 2.0F;
}
public EntityFallingBlockNT(World world, double x, double y, double z, Block block) {
this(world, x, y, z, block, 0);
}
public EntityFallingBlockNT(World world, double x, double y, double z, Block block, int meta) {
super(world);
this.canDrop = true;
this.damageCap = 40;
this.damageAmount = 2.0F;
this.fallingBlock = block;
this.dataWatcher.updateObject(10, Block.getIdFromBlock(fallingBlock));
this.fallingMeta = meta;
this.dataWatcher.updateObject(11, fallingMeta);
this.preventEntitySpawning = true;
this.setPosition(x, y, z);
this.motionX = 0.0D;
this.motionY = 0.0D;
this.motionZ = 0.0D;
this.prevPosX = x;
this.prevPosY = y;
this.prevPosZ = z;
}
@Override protected void entityInit() {
this.dataWatcher.addObject(10, new Integer(0));
this.dataWatcher.addObject(11, new Integer(0));
}
public Block getBlock() {
if(this.fallingBlock != null) return this.fallingBlock;
this.fallingBlock = Block.getBlockById(this.dataWatcher.getWatchableObjectInt(10));
return this.fallingBlock;
}
public int getMeta() {
if(this.fallingMeta != -1) return this.fallingMeta;
this.fallingMeta = 0;
this.fallingMeta = this.dataWatcher.getWatchableObjectInt(11);
return this.fallingMeta;
}
@Override protected boolean canTriggerWalking() { return false; }
@Override public boolean canBeCollidedWith() { return !this.isDead; }
public void onUpdate() {
if(this.getBlock().getMaterial() == Material.air) {
this.setDead();
} else {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
++this.fallingTicks;
this.motionY -= 0.04D;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.98D;
this.motionY *= 0.98D;
this.motionZ *= 0.98D;
if(!this.worldObj.isRemote) {
int x = MathHelper.floor_double(this.posX);
int y = MathHelper.floor_double(this.posY);
int z = MathHelper.floor_double(this.posZ);
if(this.fallingTicks == 1) {
if(this.worldObj.getBlock(x, y, z) != this.getBlock()) {
this.setDead();
return;
}
this.worldObj.setBlockToAir(x, y, z);
}
if(this.onGround) {
this.motionX *= 0.7D;
this.motionZ *= 0.7D;
this.motionY *= -0.5D;
if(this.worldObj.getBlock(x, y, z) != Blocks.piston_extension) {
this.setDead();
if(!this.destroyOnLand && replacementCheck(x, y, z) && this.worldObj.setBlock(x, y, z, this.getBlock(), this.getMeta(), 3)) {
if(this.getBlock() instanceof BlockFalling) ((BlockFalling) this.getBlock()).func_149828_a(this.worldObj, x, y, z, this.getMeta());
if(this.getBlock() instanceof BlockFallingNT) ((BlockFallingNT) this.getBlock()).onLand(this.worldObj, x, y, z, this.getMeta());
if(this.tileNBT != null && this.getBlock() instanceof ITileEntityProvider) {
TileEntity tileentity = this.worldObj.getTileEntity(x, y, z);
if(tileentity != null) {
NBTTagCompound nbt = new NBTTagCompound();
tileentity.writeToNBT(nbt);
Iterator it = this.tileNBT.func_150296_c().iterator();
while(it.hasNext()) {
String s = (String) it.next();
NBTBase nbtbase = this.tileNBT.getTag(s);
if(!s.equals("x") && !s.equals("y") && !s.equals("z")) {
nbt.setTag(s, nbtbase.copy());
}
}
tileentity.readFromNBT(nbt);
tileentity.markDirty();
}
}
} else if(this.canDrop && !this.destroyOnLand) {
this.entityDropItem(new ItemStack(this.getBlock(), 1, this.getBlock().damageDropped(this.getMeta())), 0.0F);
}
}
} else if(this.fallingTicks > 100 && !this.worldObj.isRemote && (y < 1 || y > 256) || this.fallingTicks > 600) {
if(this.canDrop) {
this.entityDropItem(new ItemStack(this.getBlock(), 1, this.getBlock().damageDropped(this.getMeta())), 0.0F);
}
this.setDead();
}
}
}
}
public boolean replacementCheck(int x, int y, int z) {
return worldObj.getBlock(x, y, z).isReplaceable(worldObj, x, y, z) && this.getBlock().canBlockStay(worldObj, x, y, z);
}
@Override
protected void fall(float fallDistance) {
if(this.canHurtEntities) {
int fall = MathHelper.ceiling_float_int(fallDistance - 1.0F);
if(fall > 0) {
ArrayList arraylist = new ArrayList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox));
boolean isAnvil = this.getBlock() == Blocks.anvil;
DamageSource damagesource = isAnvil ? DamageSource.anvil : DamageSource.fallingBlock;
Iterator iterator = arraylist.iterator();
while(iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
entity.attackEntityFrom(damagesource, (float) Math.min(MathHelper.floor_float((float) fall * this.damageAmount), this.damageCap));
}
if(isAnvil && (double) this.rand.nextFloat() < 0.05D + (double) fall * 0.05D) {
int j = this.getMeta() >> 2;
int k = this.getMeta() & 3;
++j;
if(j > 2) {
this.destroyOnLand = true;
} else {
this.fallingMeta = k | j << 2;
}
}
}
}
}
@Override
protected void writeEntityToNBT(NBTTagCompound nbt) {
nbt.setByte("Tile", (byte) Block.getIdFromBlock(this.fallingBlock));
nbt.setInteger("TileID", Block.getIdFromBlock(this.fallingBlock));
nbt.setByte("Data", (byte) this.fallingMeta);
nbt.setByte("Time", (byte) this.fallingTicks);
nbt.setBoolean("DropItem", this.canDrop);
nbt.setBoolean("HurtEntities", this.canHurtEntities);
nbt.setFloat("FallHurtAmount", this.damageAmount);
nbt.setInteger("FallHurtMax", this.damageCap);
if(this.tileNBT != null) {
nbt.setTag("TileEntityData", this.tileNBT);
}
}
@Override
protected void readEntityFromNBT(NBTTagCompound nbt) {
if(nbt.hasKey("TileID", 99)) {
this.fallingBlock = Block.getBlockById(nbt.getInteger("TileID"));
} else {
this.fallingBlock = Block.getBlockById(nbt.getByte("Tile") & 255);
}
this.fallingMeta = nbt.getByte("Data") & 255;
this.fallingTicks = nbt.getByte("Time") & 255;
if(nbt.hasKey("HurtEntities", 99)) {
this.canHurtEntities = nbt.getBoolean("HurtEntities");
this.damageAmount = nbt.getFloat("FallHurtAmount");
this.damageCap = nbt.getInteger("FallHurtMax");
} else if(this.fallingBlock == Blocks.anvil) {
this.canHurtEntities = true;
}
if(nbt.hasKey("DropItem", 99)) {
this.canDrop = nbt.getBoolean("DropItem");
}
if(nbt.hasKey("TileEntityData", 10)) {
this.tileNBT = nbt.getCompoundTag("TileEntityData");
}
if(this.fallingBlock.getMaterial() == Material.air) {
this.fallingBlock = Blocks.sand;
}
}
public void func_145806_a(boolean p_145806_1_) {
this.canHurtEntities = p_145806_1_;
}
@Override
public void addEntityCrashInfo(CrashReportCategory report) {
super.addEntityCrashInfo(report);
report.addCrashSection("Immitating block ID", Integer.valueOf(Block.getIdFromBlock(this.fallingBlock)));
report.addCrashSection("Immitating block data", Integer.valueOf(this.fallingMeta));
}
@Override
@SideOnly(Side.CLIENT)
public float getShadowSize() {
return 0.0F;
}
@SideOnly(Side.CLIENT)
public World getWorldForRender() {
return this.worldObj;
}
@Override
@SideOnly(Side.CLIENT)
public boolean canRenderOnFire() {
return false;
}
public Block getBlockForRender() {
return this.getBlock();
}
}

View File

@ -5,7 +5,6 @@ import java.util.List;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.bomb.BlockTaint;
import com.hbm.entity.effect.EntityNukeCloudSmall;
import com.hbm.entity.effect.EntityNukeTorex;
import com.hbm.entity.logic.EntityBalefire;
import com.hbm.entity.logic.EntityNukeExplosionMK5;

View File

@ -6,6 +6,7 @@ import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.entity.grenade.EntityGrenadeTau;
import com.hbm.entity.grenade.EntityGrenadeZOMG;
import com.hbm.entity.item.EntityFallingBlockNT;
import com.hbm.entity.missile.EntityMissileAntiBallistic;
import com.hbm.entity.missile.EntityMissileBase;
import com.hbm.entity.particle.EntityChlorineFX;
@ -29,7 +30,6 @@ import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.entity.item.EntityTNTPrimed;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.player.EntityPlayer;
@ -406,7 +406,7 @@ public class ExplosionChaos {
public static void pDestruction(World world, int x, int y, int z) {
EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), world.getBlock(x, y, z), world.getBlockMetadata(x, y, z));
EntityFallingBlockNT entityfallingblock = new EntityFallingBlockNT(world, (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), world.getBlock(x, y, z), world.getBlockMetadata(x, y, z));
world.spawnEntityInWorld(entityfallingblock);
}

View File

@ -6,14 +6,10 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import com.hbm.util.fauxpointtwelve.BlockPos;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.World;

View File

@ -3,21 +3,14 @@ package com.hbm.items.tool;
import java.util.List;
import com.hbm.entity.effect.EntityNukeTorex;
import com.hbm.handler.pollution.PollutionHandler;
import com.hbm.handler.pollution.PollutionHandler.PollutionType;
import com.hbm.lib.Library;
import com.hbm.util.TrackerUtil;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.entity.EntityTracker;
import net.minecraft.entity.EntityTrackerEntry;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IntHashMap;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
public class ItemWandD extends Item {

View File

@ -714,6 +714,7 @@ public class ClientProxy extends ServerProxy {
RenderingRegistry.registerEntityRenderingHandler(EntityMovingPackage.class, new RenderMovingPackage());
RenderingRegistry.registerEntityRenderingHandler(EntityTNTPrimedBase.class, new RenderTNTPrimedBase());
RenderingRegistry.registerEntityRenderingHandler(EntityDeliveryDrone.class, new RenderDeliveryDrone());
RenderingRegistry.registerEntityRenderingHandler(EntityFallingBlockNT.class, new RenderFallingBlockNT());
//mobs
RenderingRegistry.registerEntityRenderingHandler(EntityCreeperNuclear.class, new RenderCreeperUniversal(RefStrings.MODID + ":" + "textures/entity/creeper.png", RefStrings.MODID + ":" + "textures/entity/creeper_armor.png").setSwellMod(5F));
RenderingRegistry.registerEntityRenderingHandler(EntityCreeperTainted.class, new RenderCreeperUniversal(RefStrings.MODID + ":" + "textures/entity/creeper_tainted.png", RefStrings.MODID + ":" + "textures/entity/creeper_armor_taint.png"));

View File

@ -0,0 +1,71 @@
package com.hbm.render.entity.item;
import org.lwjgl.opengl.GL11;
import com.hbm.blocks.BlockFallingNT;
import com.hbm.entity.item.EntityFallingBlockNT;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class RenderFallingBlockNT extends Render {
private final RenderBlocks renderBlocks = new RenderBlocks();
public RenderFallingBlockNT() {
this.shadowSize = 0.5F;
}
public void doRender(EntityFallingBlockNT entity, double x, double y, double z, float f0, float f1) {
World world = entity.getWorldForRender();
Block block = entity.getBlockForRender();
int iX = MathHelper.floor_double(entity.posX);
int iY = MathHelper.floor_double(entity.posY);
int iZ = MathHelper.floor_double(entity.posZ);
if(block != null && block != world.getBlock(iX, iY, iZ)) {
GL11.glPushMatrix();
GL11.glTranslated(x, y, z);
this.bindEntityTexture(entity);
GL11.glDisable(GL11.GL_LIGHTING);
this.renderBlocks.blockAccess = world;
if(block instanceof BlockFallingNT && ((BlockFallingNT) block).shouldOverrideRenderer()) {
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
((BlockFallingNT) block).overrideRenderer(entity, renderBlocks, tessellator);
tessellator.draw();
} else {
this.renderBlocks.setRenderBoundsFromBlock(block);
this.renderBlocks.renderBlockSandFalling(block, world, iX, iY, iZ, entity.fallingMeta);
}
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
}
protected ResourceLocation getEntityTexture(EntityFallingBlockNT entity) {
return TextureMap.locationBlocksTexture;
}
@Override
protected ResourceLocation getEntityTexture(Entity entity) {
return this.getEntityTexture((EntityFallingBlockNT) entity);
}
@Override
public void doRender(Entity entity, double x, double y, double z, float f0, float f1) {
this.doRender((EntityFallingBlockNT) entity, x, y, z, f0, f1);
}
}

View File

@ -22,7 +22,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;