use of net.minecraftforge.fluids.BlockFluidBase in project Minechem by iopleke.
the class FluidItemRenderingHandler method renderItem.
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
Fluid fluid = ((BlockFluidBase) ((ItemBlock) item.getItem()).field_150939_a).getFluid();
if (fluid instanceof FluidElement) {
RenderingUtil.setColorForElement(((FluidElement) fluid).element);
} else if (fluid instanceof FluidMolecule) {
MoleculeEnum molecule = ((FluidMolecule) fluid).molecule;
GL11.glColor3f(molecule.red, molecule.green, molecule.blue);
}
IIcon icon = ((ItemBlock) item.getItem()).field_150939_a.getBlockTextureFromSide(0);
switch(type) {
case INVENTORY:
RenderingUtil.drawTexturedRectUV(0, 0, 0, 16, 16, icon);
break;
case EQUIPPED_FIRST_PERSON:
case EQUIPPED:
ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F);
break;
case ENTITY:
EntityItem entityItem = (EntityItem) data[1];
if (entityItem.worldObj == null) {
float angle = (Minecraft.getSystemTime() % 8000L) / 8000.0F * 360.0F;
GL11.glPushMatrix();
GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.2F, -0.5F, 0.0F);
renderItemAsEntity(item, icon);
GL11.glPopMatrix();
} else {
renderItemAsEntity(item, icon);
}
break;
default:
break;
}
}
use of net.minecraftforge.fluids.BlockFluidBase in project ICBM-Classic by BuiltBrokenModding.
the class BlastSonic method doExplode.
@Override
public // TODO Rewrite this entire method
boolean doExplode(// TODO Rewrite this entire method
int callCount) {
if (callCount <= 0) {
firstTick();
}
// TODO scale off of size & callcout
final int radius = Math.max(1, this.callCount);
if (callCount % 4 == 0) {
if (isThreadCompleted()) {
if (!getThreadResults().isEmpty()) {
final Iterator<BlockPos> it = getThreadResults().iterator();
while (it.hasNext()) {
final BlockPos targetPosition = it.next();
final double distance = location.distance(targetPosition);
// Only act on blocks inside the current radius TODO scale radius separate from ticks so we can control block creation
if (distance <= radius) {
// Remove
it.remove();
// Get data
final IBlockState blockState = world.getBlockState(targetPosition);
final Block block = blockState.getBlock();
// Only act on movable blocks
if (!block.isAir(blockState, world, targetPosition) && blockState.getBlockHardness(world, targetPosition) >= 0) {
// Trigger explosions
if (block == BlockReg.blockExplosive) {
((TileEntityExplosive) this.world().getTileEntity(targetPosition)).trigger(false);
}
// Destroy block
this.world().setBlockToAir(targetPosition);
// Create floating block
if (!(block instanceof BlockFluidBase || block instanceof IFluidBlock) && this.world().rand.nextFloat() < 0.1) {
this.world().spawnEntity(new EntityFlyingBlock(this.world(), targetPosition, blockState));
}
}
}
}
} else {
isAlive = false;
if (ConfigDebug.DEBUG_THREADS) {
String msg = String.format("BlastSonic#doPostExplode() -> Thread failed to find blocks to edit. Either thread failed or no valid blocks were found in range." + "\nWorld = %s " + "\nThread = %s" + "\nSize = %s" + "\nPos = %s", world, getThread(), size, location);
ICBMClassic.logger().error(msg);
}
}
}
}
// TODO scale to radius
final int entityEffectRadius = 2 * this.callCount;
final AxisAlignedBB bounds = new AxisAlignedBB(location.x() - entityEffectRadius, location.y() - entityEffectRadius, location.z() - entityEffectRadius, location.x() + entityEffectRadius, location.y() + entityEffectRadius, location.z() + entityEffectRadius);
final List<Entity> allEntities = this.world().getEntitiesWithinAABB(Entity.class, bounds);
for (Entity entity : allEntities) {
if (entity instanceof IMissile) {
// TODO change from guided to dummy fire
((IMissile) entity).destroyMissile(true);
} else if (!(entity instanceof EntityPlayer) || !((EntityPlayer) entity).isCreative()) {
// Get difference
double xDelta = entity.posX - location.x();
double yDelta = entity.posY - location.y();
double zDelta = entity.posZ - location.z();
// Normalize
float distance = MathHelper.sqrt(xDelta * xDelta + yDelta * yDelta + zDelta * zDelta);
xDelta = xDelta / (double) distance;
yDelta = yDelta / (double) distance;
zDelta = zDelta / (double) distance;
// Scale
final double scale = Math.max(0, (1 - (distance / getBlastRadius()))) * 3;
xDelta *= scale;
yDelta *= scale;
zDelta *= scale;
entity.motionX += xDelta * this.world().rand.nextFloat() * 0.2;
entity.motionY += Math.abs(yDelta * this.world().rand.nextFloat()) * 1;
entity.motionZ += zDelta * this.world().rand.nextFloat() * 0.2;
}
}
return this.callCount > this.getBlastRadius();
}
use of net.minecraftforge.fluids.BlockFluidBase in project MorePlanets by SteveKunG.
the class PathNavigateGroundMP method getPathablePosY.
private int getPathablePosY() {
if (this.entity.isInWater() && this.getCanSwim()) {
int i = (int) this.entity.getEntityBoundingBox().minY;
Block block = this.world.getBlockState(new BlockPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ))).getBlock();
int j = 0;
while (block == Blocks.FLOWING_WATER || block == Blocks.WATER || block instanceof BlockFluidBase && this.world.getBlockState(new BlockPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ))).getMaterial() == Material.WATER) {
++i;
block = this.world.getBlockState(new BlockPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ))).getBlock();
++j;
if (j > 16) {
return (int) this.entity.getEntityBoundingBox().minY;
}
}
return i;
} else {
return (int) (this.entity.getEntityBoundingBox().minY + 0.5D);
}
}
use of net.minecraftforge.fluids.BlockFluidBase in project Gaia-Dimension by Andromander.
the class GDLiquidBismuth method mixFluids.
@Override
public void mixFluids(World world, BlockPos pos) {
for (EnumFacing side : EnumFacing.VALUES) {
if (side != EnumFacing.DOWN) {
IBlockState offset = world.getBlockState(pos.offset(side));
if (offset.getMaterial().isLiquid()) {
if (offset.getBlock() == GDBlocks.sweet_muck_block || offset.getBlock() == GDBlocks.superhot_magma_block) {
world.setBlockState(pos, GDBlocks.active_rock.getDefaultState());
this.playSound(world, pos);
break;
} else if (offset.getBlock() instanceof BlockFluidBase || offset.getBlock() instanceof BlockLiquid) {
if (offset.getMaterial() == Material.WATER) {
world.setBlockState(pos, GDBlocks.impure_rock.getDefaultState());
this.playSound(world, pos);
break;
}
}
}
}
}
}
use of net.minecraftforge.fluids.BlockFluidBase in project Gaia-Dimension by Andromander.
the class GDFluidsRegister method registerFluidModel.
@SideOnly(Side.CLIENT)
public static void registerFluidModel(BlockFluidBase fluid) {
final Item item = Item.getItemFromBlock(fluid);
net.minecraft.client.renderer.block.model.ModelBakery.registerItemVariants(item);
String domain = fluid.getRegistryName() == null ? "minecraft" : fluid.getRegistryName().getResourceDomain();
ModelResourceLocation modelResourceLocation = new ModelResourceLocation(new ResourceLocation(domain, "blocks/fluids"), fluid.getFluid().getName());
ModelLoader.setCustomMeshDefinition(item, androsa.gaiadimension.registry.MeshDefinitionFix.create(stack -> modelResourceLocation));
ModelLoader.setCustomStateMapper(fluid, new net.minecraft.client.renderer.block.statemap.StateMapperBase() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
return modelResourceLocation;
}
});
}
Aggregations