added solid hitbox to the soyuz launcher

This commit is contained in:
HbmMods 2020-06-02 21:59:01 +02:00
parent 2b3ba26a26
commit b71d4e09d2
5 changed files with 203 additions and 13 deletions

View File

@ -147,7 +147,7 @@ public abstract class BlockDummyable extends BlockContainer {
dir = ForgeDirection.getOrientation(4);
}
if(!MultiblockHandlerXR.checkSpace(world, x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, getDimensions(), x, y, z, dir)) {
if(!checkRequirement(world, x, y, z, dir, o)) {
world.setBlockToAir(x, y, z);
if(!pl.capabilities.isCreativeMode) {
@ -169,13 +169,22 @@ public abstract class BlockDummyable extends BlockContainer {
}
world.setBlock(x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, this, dir.ordinal() + offset, 3);
MultiblockHandlerXR.fillSpace(world, x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, getDimensions(), this, dir);
fillSpace(world, x, y, z, dir, o);
world.scheduleBlockUpdate(x, y, z, this, 1);
world.scheduleBlockUpdate(x, y, z, this, 2);
super.onBlockPlacedBy(world, x, y, z, player, itemStack);
}
protected boolean checkRequirement(World world, int x, int y, int z, ForgeDirection dir, int o) {
return MultiblockHandlerXR.checkSpace(world, x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, getDimensions(), x, y, z, dir);
}
protected void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) {
MultiblockHandlerXR.fillSpace(world, x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, getDimensions(), this, dir);
}
//"upgrades" regular dummy blocks to ones with the extra flag
public void makeExtra(World world, int x, int y, int z) {

View File

@ -1,25 +1,40 @@
package com.hbm.blocks.machine;
import java.util.Random;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ModBlocks;
import com.hbm.handler.MultiblockHandlerXR;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.TileEntitySoyuzLauncher;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class SoyuzLauncher extends BlockContainer {
public class SoyuzLauncher extends BlockDummyable {
public SoyuzLauncher(Material p_i45386_1_) {
super(p_i45386_1_);
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntitySoyuzLauncher();
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= ForgeDirection.UNKNOWN.ordinal())
return new TileEntitySoyuzLauncher();
return null;
}
@Override
@ -44,15 +59,180 @@ public class SoyuzLauncher extends BlockContainer {
return true;
} else if(!player.isSneaking())
{
TileEntitySoyuzLauncher entity = (TileEntitySoyuzLauncher) world.getTileEntity(x, y, z);
int[] pos = this.findCore(world, x, y, z);
if(pos == null)
return false;
TileEntitySoyuzLauncher entity = (TileEntitySoyuzLauncher) world.getTileEntity(pos[0], pos[1], pos[2]);
if(entity != null)
{
FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_soyuz_launcher, world, x, y, z);
FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_soyuz_launcher, world, pos[0], pos[1], pos[2]);
}
return true;
} else {
return false;
}
}
int height = 4;
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
if(!(player instanceof EntityPlayer))
return;
EntityPlayer pl = (EntityPlayer) player;
int o = -getOffset();
ForgeDirection dir = ForgeDirection.EAST;
/*if(i == 0)
{
dir = ForgeDirection.getOrientation(2);
}
if(i == 1)
{
dir = ForgeDirection.getOrientation(5);
}
if(i == 2)
{
dir = ForgeDirection.getOrientation(3);
}
if(i == 3)
{
dir = ForgeDirection.getOrientation(4);
}*/
if(!checkRequirement(world, x, y, z, dir, o)) {
world.setBlockToAir(x, y, z);
if(!pl.capabilities.isCreativeMode) {
ItemStack stack = pl.inventory.mainInventory[pl.inventory.currentItem];
Item item = Item.getItemFromBlock(this);
if(stack == null) {
pl.inventory.mainInventory[pl.inventory.currentItem] = new ItemStack(this);
} else {
if(stack.getItem() != item || stack.stackSize == stack.getMaxStackSize()) {
pl.inventory.addItemStackToInventory(new ItemStack(this));
} else {
pl.getHeldItem().stackSize++;
}
}
}
return;
}
world.setBlock(x + dir.offsetX * o , y + dir.offsetY * o + height, z + dir.offsetZ * o, this, dir.ordinal() + offset, 3);
fillSpace(world, x, y, z, dir, o);
world.scheduleBlockUpdate(x, y, z, this, 1);
world.scheduleBlockUpdate(x, y, z, this, 2);
super.onBlockPlacedBy(world, x, y, z, player, itemStack);
}
protected boolean checkRequirement(World world, int x, int y, int z, ForgeDirection dir, int o) {
x = x + dir.offsetX * o;
y = y + dir.offsetY * o + height;
z = z + dir.offsetZ * o;
if(!MultiblockHandlerXR.checkSpace(world, x, y, z, new int[] { 0, 1, 6, 6, 6, 6 }, x, y, z, dir)) return false;
if(!MultiblockHandlerXR.checkSpace(world, x, y, z, new int[] { -2, 4, -3, 6, -3, 6 }, x, y, z, dir)) return false;
if(!MultiblockHandlerXR.checkSpace(world, x, y, z, new int[] { -2, 4, 6, -3, -3, 6 }, x, y, z, dir)) return false;
if(!MultiblockHandlerXR.checkSpace(world, x, y, z, new int[] { -2, 4, 6, -3, 6, -3 }, x, y, z, dir)) return false;
if(!MultiblockHandlerXR.checkSpace(world, x, y, z, new int[] { -2, 4, -3, 6, 6, -3 }, x, y, z, dir)) return false;
if(!MultiblockHandlerXR.checkSpace(world, x, y, z, new int[] { 0, 4, 1, 1, -6, 8 }, x, y, z, dir)) return false;
if(!MultiblockHandlerXR.checkSpace(world, x, y, z, new int[] { 0, 4, 2, 2, 9, -5 }, x, y, z, dir)) return false;
return true;
}
protected void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) {
x = x + dir.offsetX * o;
y = y + dir.offsetY * o + height;
z = z + dir.offsetZ * o;
MultiblockHandlerXR.fillSpace(world, x, y, z, new int[] { 0, 1, 6, 6, 6, 6 }, this, dir);
MultiblockHandlerXR.fillSpace(world, x, y, z, new int[] { -2, 4, -3, 6, -3, 6 }, this, dir);
MultiblockHandlerXR.fillSpace(world, x, y, z, new int[] { -2, 4, 6, -3, -3, 6 }, this, dir);
MultiblockHandlerXR.fillSpace(world, x, y, z, new int[] { -2, 4, 6, -3, 6, -3 }, this, dir);
MultiblockHandlerXR.fillSpace(world, x, y, z, new int[] { -2, 4, -3, 6, 6, -3 }, this, dir);
MultiblockHandlerXR.fillSpace(world, x, y, z, new int[] { 0, 4, 1, 1, -6, 8 }, this, dir);
MultiblockHandlerXR.fillSpace(world, x, y, z, new int[] { 0, 4, 2, 2, 9, -5 }, this, dir);
//for(int a = )
}
@Override
public int[] getDimensions() {
//because we'll implement our own gnarly behavior here
return new int[] { 0, 0, 0, 0, 0, 0 };
}
@Override
public int getOffset() {
return 0;
}
private final Random field_149933_a = new Random();
private static boolean keepInventory;
@Override
public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int i)
{
if (!keepInventory)
{
ISidedInventory tileentityfurnace = (ISidedInventory)world.getTileEntity(x, y, z);
if (tileentityfurnace != null)
{
for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1)
{
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
if (itemstack != null)
{
float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
while (itemstack.stackSize > 0)
{
int j1 = this.field_149933_a.nextInt(21) + 10;
if (j1 > itemstack.stackSize)
{
j1 = itemstack.stackSize;
}
itemstack.stackSize -= j1;
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
if (itemstack.hasTagCompound())
{
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
float f3 = 0.05F;
entityitem.motionX = (float)this.field_149933_a.nextGaussian() * f3;
entityitem.motionY = (float)this.field_149933_a.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float)this.field_149933_a.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, p_149749_5_);
}
}
super.breakBlock(world, x, y, z, p_149749_5_, i);
}
}

View File

@ -447,7 +447,8 @@ public class ModEventHandler
EntityPlayer player = event.player;
if(!player.worldObj.isRemote && player.getUniqueID().toString().equals("c874fd4e-5841-42e4-8f77-70efd5881bc1"))
if(!player.worldObj.isRemote && (player.getUniqueID().toString().equals("c874fd4e-5841-42e4-8f77-70efd5881bc1") ||
player.getUniqueID().toString().equals("6a058220-7d86-4f29-817b-418eb98bd842")))
player.getEntityData().setFloat("hfr_radiation", player.getEntityData().getFloat("hfr_radiation" + 0.05F));
if(!player.worldObj.isRemote && event.phase == TickEvent.Phase.START) {

View File

@ -15,7 +15,7 @@ public class RenderSoyuzLauncher extends TileEntitySpecialRenderer {
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float inter) {
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y, (float) z + 0.5F);
GL11.glTranslatef((float) x + 0.5F, (float) y - 4, (float) z + 0.5F);
TileEntitySoyuzLauncher launcher = (TileEntitySoyuzLauncher)te;

View File

@ -120,10 +120,10 @@ public class TileEntitySoyuzLauncher extends TileEntityMachineBase implements IS
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "smoke");
data.setString("mode", "shockRand");
data.setInteger("count", 35);
data.setInteger("count", 50);
data.setDouble("strength", worldObj.rand.nextGaussian() * 3 + 6);
data.setDouble("posX", xCoord + 0.5);
data.setDouble("posY", yCoord + 1);
data.setDouble("posY", yCoord - 3);
data.setDouble("posZ", zCoord + 0.5);
MainRegistry.proxy.effectNT(data);
@ -172,7 +172,7 @@ public class TileEntitySoyuzLauncher extends TileEntityMachineBase implements IS
EntitySoyuz soyuz = new EntitySoyuz(worldObj);
soyuz.setSkin(this.getType());
soyuz.mode = this.mode;
soyuz.setLocationAndAngles(xCoord + 0.5, yCoord + 5, zCoord + 0.5, 0, 0);
soyuz.setLocationAndAngles(xCoord + 0.5, yCoord + 1, zCoord + 0.5, 0, 0);
worldObj.spawnEntityInWorld(soyuz);
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:entity.soyuzTakeoff", 100F, 1.1F);