Java Code Examples for net.minecraft.tileentity.TileEntity

The following examples show how to use net.minecraft.tileentity.TileEntity. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: TofuCraftReload   Source File: ItemTofuEnergyContained.java    License: MIT License 6 votes vote down vote up
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
    super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
    if (!worldIn.isRemote && getEnergy(stack) < getEnergyMax(stack)) {
        BlockPos entityPos = new BlockPos(entityIn.posX, entityIn.posY, entityIn.posZ);
        List<TileEntity> list = TofuNetwork.toTiles(TofuNetwork.Instance.getExtractableWithinRadius(
                worldIn, entityPos, 64));
        if (!list.isEmpty()) {
            int toDrain = getEnergyMax(stack) - getEnergy(stack);
            for (TileEntity te : list) {
                if (te instanceof TileEntitySenderBase &&
                        ((TileEntitySenderBase) te).isValid() &&
                        te.getPos().getDistance(entityPos.getX(), entityPos.getY(), entityPos.getZ()) <= ((TileEntitySenderBase) te).getRadius()) {
                    toDrain -= ((ITofuEnergy) te).drain(Math.min(toDrain, ((TileEntitySenderBase) te).getTransferPower()), false);
                    if (toDrain == 0) break;
                }
            }
            fill(stack, getEnergyMax(stack) - getEnergy(stack) - toDrain, false);
        }
    }
}
 
Example 2
Source Project: Framez   Source File: StatementManager.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static List<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity entity) {
	List<ITriggerExternal> result;

	if (entity instanceof IOverrideDefaultStatements) {
		result = ((IOverrideDefaultStatements) entity).overrideTriggers();
		if (result != null) {
			return result;
		}
	}
	
	result = new LinkedList<ITriggerExternal>();
	
	for (ITriggerProvider provider : triggerProviders) {
		Collection<ITriggerExternal> toAdd = provider.getExternalTriggers(side, entity);

		if (toAdd != null) {
			for (ITriggerExternal t : toAdd) {
				if (!result.contains(t)) {
					result.add(t);
				}
			}
		}
	}

	return result;
}
 
Example 3
Source Project: Valkyrien-Skies   Source File: TileEntityPassengerChair.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public TileEntity createRelocatedTile(BlockPos newPos, ShipTransform transform,
    CoordinateSpaceType coordinateSpaceType) {
    TileEntityPassengerChair relocatedTile = new TileEntityPassengerChair();
    relocatedTile.setWorld(getWorld());
    relocatedTile.setPos(newPos);

    if (chairEntityUUID != null) {
        EntityMountableChair chairEntity = (EntityMountableChair) ((WorldServer) getWorld())
            .getEntityFromUuid(chairEntityUUID);
        if (chairEntity != null) {
            Vec3d newMountPos = transform
                .transform(chairEntity.getMountPos(), TransformType.SUBSPACE_TO_GLOBAL);
            chairEntity.setMountValues(newMountPos, coordinateSpaceType, newPos);
        } else {
            chairEntityUUID = null;
        }
    }

    relocatedTile.chairEntityUUID = this.chairEntityUUID;
    // Move everything to the new tile.
    this.chairEntityUUID = null;
    this.markDirty();
    return relocatedTile;
}
 
Example 4
Source Project: Wizardry   Source File: BlockJar.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void breakBlock(@NotNull World worldIn, @NotNull BlockPos pos, @NotNull IBlockState state) {
	ItemStack stack = new ItemStack(ModItems.JAR_ITEM);
	TileEntity entity = worldIn.getTileEntity(pos);
	if (entity instanceof TileJar) {
		TileJar jar = (TileJar) entity;
		if (jar.fairy == null) {
			return;
		}
		stack.setItemDamage(2);
		NBTHelper.setTag(stack, "fairy", jar.fairy.serializeNBT());
	}
	spawnAsEntity(worldIn, pos, stack);

	super.breakBlock(worldIn, pos, state);
}
 
Example 5
Source Project: NEI-Integration   Source File: TileEntityDumper.java    License: MIT License 6 votes vote down vote up
@Override
public Iterable<String[]> dump(int mode) {
    List<String[]> list = new LinkedList<String[]>();
    
    Map<Class, String> classToNameMap = ReflectionHelper.getPrivateValue(TileEntity.class, null, "field_145853_j", "classToNameMap");
    List<Class> classes = new ArrayList<Class>();
    classes.addAll(classToNameMap.keySet());
    Collections.sort(classes, new Comparator<Class>() {
        @Override
        public int compare(Class o1, Class o2) {
            if (o1 == null || o2 == null) {
                return 0;
            }
            return o1.getName().compareTo(o2.getName());
        }
    });
    
    for (Class clazz : classes) {
        if (clazz != null) {
            list.add(new String[] { clazz.getName(), classToNameMap.get(clazz) });
        }
    }
    
    return list;
}
 
Example 6
Source Project: Chisel-2   Source File: ChiselGuiHandler.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	switch (ID) {
	case 0:
		return new GuiChisel(player.inventory, new InventoryChiselSelection(player.getCurrentEquippedItem()));
	case 1:
		TileEntity tileentity = world.getTileEntity(x, y, z);
		if (tileentity instanceof TileEntityAutoChisel)
			return new GuiAutoChisel(player.inventory, (TileEntityAutoChisel) tileentity);
	case 2:
		TileEntity tileEntity = world.getTileEntity(x, y, z);
		if (tileEntity instanceof TileEntityPresent)
			return new GuiPresent(player.inventory, (TileEntityPresent) tileEntity);
	default:
		return null;
	}
}
 
Example 7
Source Project: Framez   Source File: SchematicTile.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Places the block in the world, at the location specified in the slot.
 */
@Override
public void placeInWorld(IBuilderContext context, int x, int y, int z, LinkedList<ItemStack> stacks) {
	super.placeInWorld(context, x, y, z, stacks);

	if (block.hasTileEntity(meta)) {
		TileEntity tile = context.world().getTileEntity(x, y, z);

		tileNBT.setInteger("x", x);
		tileNBT.setInteger("y", y);
		tileNBT.setInteger("z", z);

		if (tile != null) {
			tile.readFromNBT(tileNBT);
		}
	}
}
 
Example 8
@Override
public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) {
	int range = 6;
	range *= range;

	double dist = (x - supertile.xCoord) * (x - supertile.xCoord) + (y - supertile.yCoord) * (y - supertile.yCoord) + (z - supertile.zCoord) * (z - supertile.zCoord);
	if(range >= dist) {
		TileEntity tile = player.worldObj.getTileEntity(x, y, z);
		if(tile instanceof IManaCollector) {
			linkedCollector = tile;
			return true;
		}
	}

	return false;
}
 
Example 9
Source Project: BigReactors   Source File: AdjacentInventoryHelper.java    License: MIT License 6 votes vote down vote up
/**
 * @param te The new tile entity for this helper to cache.
 * @return True if this helper's wrapped inventory changed, false otherwise.
 */
public boolean set(TileEntity te) {
	if(entity == te) { return false; }
	
	if(te == null) {
		duct = null;
		pipe = null;
		inv = null;
	}
	else if(ModHelperBase.useCofh && te instanceof IItemDuct) {
		setDuct((IItemDuct)te);
	}
	else if(ModHelperBase.useBuildcraftTransport && te instanceof IPipeTile) {
		setPipe((IPipeTile)te);
	}
	else if(te instanceof IInventory) {
		setInv(te);
	}
	
	entity = te;
	return true;
}
 
Example 10
Source Project: Cyberware   Source File: BlockBlueprintArchive.java    License: MIT License 6 votes vote down vote up
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
	TileEntity tileentity = worldIn.getTileEntity(pos);
	
	if (tileentity instanceof TileEntityBlueprintArchive)
	{
		/*if (player.isCreative() && player.isSneaking())
		{
			TileEntityScanner scanner = ((TileEntityScanner) tileentity);
			scanner.ticks = CyberwareConfig.SCANNER_TIME - 200;
		}*/
		player.openGui(Cyberware.INSTANCE, 4, worldIn, pos.getX(), pos.getY(), pos.getZ());
	}
	
	return true;
	
}
 
Example 11
Source Project: TofuCraftReload   Source File: BlockSaltFurnace.java    License: MIT License 6 votes vote down vote up
public static void setState(boolean active, World worldIn, BlockPos pos)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);
    TileEntity tileentity = worldIn.getTileEntity(pos);
    keepInventory = true;

    if (active)
    {
        worldIn.setBlockState(pos, BlockLoader.SALTFURNACE_LIT.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
        worldIn.setBlockState(pos, BlockLoader.SALTFURNACE_LIT.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
    }
    else
    {
        worldIn.setBlockState(pos, BlockLoader.SALTFURNACE.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
        worldIn.setBlockState(pos, BlockLoader.SALTFURNACE.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
    }

    keepInventory = false;

    if (tileentity != null)
    {
        tileentity.validate();
        worldIn.setTileEntity(pos, tileentity);
    }
}
 
Example 12
@Override
public TileEntity createTileEntity(World world, int meta) {
    if (meta == 0) {
        return new TileEntityPotentiaGenerator();
    }
    if (meta == 1) {
        return new TileEntityIgnisGenerator();
    }
    if (meta == 2) {
        return new TileEntityAuramGenerator();
    }
    if (meta == 3) {
        return new TileEntityArborGenerator();
    }
    if (meta == 4) {
        return new TileEntityAerGenerator();
    }
    return super.createTileEntity(world, meta);
}
 
Example 13
Source Project: OpenPeripheral-Integration   Source File: AdapterWritingDesk.java    License: MIT License 6 votes vote down vote up
@ScriptCallable(description = "Create a symbol page from the target symbol")
public void writeSymbol(final TileEntity desk,
		@Arg(name = "deskSlot") Index deskSlot,
		@Arg(name = "notebookSlot", description = "The source symbol to copy") Index notebookSlot) {
	Preconditions.checkNotNull(MystcraftAccess.pageApi, "Functionality not available");

	final NotebookWrapper wrapper = createInventoryWrapper(desk, deskSlot);
	ItemStack page = wrapper.getPageFromSlot(notebookSlot);
	final String symbol = MystcraftAccess.pageApi.getPageSymbol(page);
	if (symbol != null) {
		FakePlayerPool.instance.executeOnPlayer((WorldServer)desk.getWorldObj(), new PlayerUser() {
			@Override
			public void usePlayer(OpenModsFakePlayer fakePlayer) {
				WRITE_SYMBOL.call(desk, fakePlayer, symbol);
			}
		});
	}
}
 
Example 14
Source Project: bartworks   Source File: BW_TileEntityContainer.java    License: MIT License 6 votes vote down vote up
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) {
    TileEntity tile = world.getTileEntity(x, y, z);
    if (tile instanceof IWrenchable && itemStack != null) {
        IWrenchable tile2 = (IWrenchable) tile;
        int meta = itemStack.getItemDamage();
        world.setBlockMetadataWithNotify(x, y, z, meta, 2);
        if (entity != null) {
            int face = MathHelper.floor_double(entity.rotationYaw * 4.0f / 360.0f + 0.5) & 0x3;
            switch (face) {
                case 0:
                    tile2.setFacing((short) 2);
                    break;
                case 1:
                    tile2.setFacing((short) 5);
                    break;
                case 2:
                    tile2.setFacing((short) 3);
                    break;
                case 3:
                    tile2.setFacing((short) 4);
                    break;
            }
        }
    }
}
 
Example 15
Source Project: qcraft-mod   Source File: BlockQuantumComputer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer player, int l, float m, float n, float o )
{
    if( player.isSneaking() )
    {
        return false;
    }

    if( !world.isRemote )
    {
        // Show GUI
        TileEntity entity = world.getTileEntity( x, y, z );
        if( entity != null && entity instanceof TileEntityQuantumComputer )
        {
            TileEntityQuantumComputer computer = (TileEntityQuantumComputer) entity;
            QCraft.openQuantumComputerGUI( player, computer );
        }
    }
    return true;
}
 
Example 16
Source Project: reactor_simulator   Source File: MultiblockTurbineSimulator.java    License: MIT License 6 votes vote down vote up
protected void markReferenceCoordDirty() {
  if (worldObj == null || worldObj.isRemote) {
    return;
  }

  CoordTriplet referenceCoord = getReferenceCoord();
  if (referenceCoord == null) {
    return;
  }

  rpmUpdateTracker.onExternalUpdate();

  TileEntity saveTe = worldObj.getTileEntity(referenceCoord.x, referenceCoord.y, referenceCoord.z);
  worldObj.markTileEntityChunkModified(referenceCoord.x, referenceCoord.y, referenceCoord.z, saveTe);
  worldObj.markBlockForUpdate(referenceCoord.x, referenceCoord.y, referenceCoord.z);
}
 
Example 17
@Override
public void isGoodForInterior() throws MultiblockValidationException {
  // Check above and below. Above must be fuel rod or control rod.
  TileEntity entityAbove = this.worldObj.getTileEntity(xCoord, yCoord + 1, zCoord);
  if (!(entityAbove instanceof TileEntityReactorFuelRodSimulator || entityAbove instanceof TileEntityReactorControlRod)) {
    throw new MultiblockValidationException(String.format("Fuel rod at %d, %d, %d must be part of a vertical column that reaches the entire height of the reactor, with a control rod on top.", xCoord, yCoord, zCoord));
  }

  // Below must be fuel rod or the base of the reactor.
  TileEntity entityBelow = this.worldObj.getTileEntity(xCoord, yCoord - 1, zCoord);
  if (entityBelow instanceof TileEntityReactorFuelRodSimulator) {
    return;
  } else if (entityBelow instanceof RectangularMultiblockTileEntityBase) {
    ((RectangularMultiblockTileEntityBase)entityBelow).isGoodForBottom();
    return;
  }

  throw new MultiblockValidationException(String.format("Fuel rod at %d, %d, %d must be part of a vertical column that reaches the entire height of the reactor, with a control rod on top.", xCoord, yCoord, zCoord));
}
 
Example 18
Source Project: ehacks-pro   Source File: DragonsFuck.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    MovingObjectPosition mop = Wrapper.INSTANCE.mc().objectMouseOver;
    if (mop.sideHit == -1) {
        return;
    }
    if (Mouse.isButtonDown(1)) {
        TileEntity entity = Wrapper.INSTANCE.world().getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
        try {
            if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && entity != null && Class.forName("eu.thesociety.DragonbornSR.DragonsRadioMod.Block.TileEntity.TileEntityRadio").isInstance(entity)) {
                Wrapper.INSTANCE.mc().displayGuiScreen((GuiScreen) Class.forName("eu.thesociety.DragonbornSR.DragonsRadioMod.Block.Gui.NGuiRadio").getConstructor(Class.forName("eu.thesociety.DragonbornSR.DragonsRadioMod.Block.TileEntity.TileEntityRadio")).newInstance(entity));
                InteropUtils.log("Gui opened", this);
                if (event.isCancelable()) {
                    event.setCanceled(true);
                }
            }
        } catch (Exception ex) {
            InteropUtils.log("&cError", this);
        }
    }
}
 
Example 19
Source Project: BigReactors   Source File: BigReactorsGUIHandler.java    License: MIT License 6 votes vote down vote up
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
		int x, int y, int z) {
	TileEntity te = world.getTileEntity(x, y, z);
	if(te == null) {
		return null;
	}
	
	if(te instanceof IMultiblockGuiHandler) {
		IMultiblockGuiHandler part = (IMultiblockGuiHandler)te;
		return part.getGuiElement(player.inventory);
	}
	else if(te instanceof IBeefGuiEntity) {
		return ((IBeefGuiEntity)te).getGUI(player);
	}
	
	return null;
}
 
Example 20
Source Project: OpenPeripheral-Integration   Source File: AdapterFrequencyOwner.java    License: MIT License 5 votes vote down vote up
@Asynchronous
@MultipleReturn
@Alias("getColours")
@ScriptCallable(returnTypes = { ReturnType.NUMBER, ReturnType.NUMBER, ReturnType.NUMBER },
		description = "Get the colours active on this chest or tank")
public int[] getColors(TileEntity frequencyOwner) {
	int frequency = FREQ.get(frequencyOwner);
	// return a map of the frequency in ComputerCraft colour format
	return new int[] {
			1 << (frequency >> 8 & 0xF),
			1 << (frequency >> 4 & 0xF),
			1 << (frequency >> 0 & 0xF)
	};
}
 
Example 21
Source Project: ExNihiloAdscensio   Source File: MessageNBTUpdate.java    License: MIT License 5 votes vote down vote up
public MessageNBTUpdate(TileEntity te)
{
	this.x = te.getPos().getX();
	this.y = te.getPos().getY();
	this.z = te.getPos().getZ();
	this.tag = te.writeToNBT(new NBTTagCompound());
}
 
Example 22
Source Project: AdvancedRocketry   Source File: BlockForceFieldProjector.java    License: MIT License 5 votes vote down vote up
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
	TileEntity tile = worldIn.getTileEntity(pos);
	
	if(tile instanceof TileForceFieldProjector)
		((TileForceFieldProjector)tile).destroyField(getFront(state));
	
	super.breakBlock(worldIn, pos, state);
}
 
Example 23
@Override
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
    Map<BlockPos, TileEntity> tiles = chunk.getTileEntityMap();
    pos.set(x, y, z);
    TileEntity tile = tiles.get(pos);
    return tile != null ? getTag(tile) : null;
}
 
Example 24
Source Project: Artifacts   Source File: BlockPedestal.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
	//Don't activate the block if the player is holding a key
	if(player.getHeldItem() != null && player.getHeldItem().getItem() == ItemPedestalKey.pedestalKeyItem) {
		return false;
	}
	
	world.playSoundEffect((double)x + 0.5, (double)y + 0.5, (double)z + 0.5, "random.door_open", 1.0f, 1.2f);
	
	if (world.isRemote)
	{
		TileEntity te = world.getTileEntity(x, y, z);
		
		if(te instanceof TileEntityDisplayPedestal) {
			String ownerName = ((TileEntityDisplayPedestal) te).ownerName;
			if(ownerName != null && !ownerName.equals("") && !ownerName.equals(player.getCommandSenderName())) {
				Minecraft.getMinecraft().ingameGUI.func_110326_a(StatCollector.translateToLocal("misc.Owned by:") + " " + ownerName, false);
			}
		}
		return true;
	}
	else
	{
		player.openGui(DragonArtifacts.instance, 0, world, x, y, z);
		return true;
	}
}
 
Example 25
public CompoundTag getTag(TileEntity tile) {
    try {
        NBTTagCompound tag = new NBTTagCompound();
        tile.writeToNBT(tag); // readTagIntoEntity
        return (CompoundTag) methodToNative.invoke(null, tag);
    } catch (Exception e) {
        MainUtil.handleError(e);
        return null;
    }
}
 
Example 26
Source Project: MyTown2   Source File: ProtectionHandlers.java    License: The Unlicense 5 votes vote down vote up
public void onAnyBlockPlacement(EntityPlayer player, BlockEvent.PlaceEvent ev) {
    if(ev.world.isRemote || ev.isCanceled()) {
        return;
    }

    if(player instanceof FakePlayer) {
        if(!ProtectionManager.getFlagValueAtLocation(FlagType.FAKERS, ev.world.provider.dimensionId, ev.x, ev.y, ev.z)) {
            ev.setCanceled(true);
        }
    } else {
        Resident res = MyTownUniverse.instance.getOrMakeResident(player);

        if (!MyTownUniverse.instance.blocks.contains(ev.world.provider.dimensionId, ev.x >> 4, ev.z >> 4)) {
            int range = Config.instance.placeProtectionRange.get();
            Volume placeBox = new Volume(ev.x-range, ev.y-range, ev.z-range, ev.x+range, ev.y+range, ev.z+range);

            if(!ProtectionManager.hasPermission(res, FlagType.MODIFY, ev.world.provider.dimensionId, placeBox)) {
                ev.setCanceled(true);
                return;
            }
        } else {
            if(!ProtectionManager.hasPermission(res, FlagType.MODIFY, ev.world.provider.dimensionId, ev.x, ev.y, ev.z)) {
                ev.setCanceled(true);
                return;
            }
        }

        if(ev.block instanceof ITileEntityProvider && ev.itemInHand != null) {
            TileEntity te = ((ITileEntityProvider) ev.block).createNewTileEntity(MinecraftServer.getServer().worldServerForDimension(ev.world.provider.dimensionId), ev.itemInHand.getItemDamage());
            if (te != null && ProtectionManager.isOwnable(te.getClass())) {
                ThreadPlacementCheck thread = new ThreadPlacementCheck(res, ev.x, ev.y, ev.z, ev.world.provider.dimensionId);
                activePlacementThreads++;
                thread.start();
            }
        }
    }
}
 
Example 27
Source Project: AdvancedRocketry   Source File: TileSpaceElevator.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onLinkStart(ItemStack item, TileEntity entity,
		EntityPlayer player, World world) {
	ItemLinker.setMasterCoords(item, this.getPos());
	ItemLinker.setDimId(item, world.provider.getDimension());
	if(!world.isRemote)
		player.sendMessage(new TextComponentString(LibVulpes.proxy.getLocalizedString("msg.linker.program")));
	return true;
}
 
Example 28
Source Project: AdvancedRocketry   Source File: BlockBeacon.java    License: MIT License 5 votes vote down vote up
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
	TileEntity tile = world.getTileEntity(pos);
	if(tile instanceof TileBeacon && DimensionManager.getInstance().isDimensionCreated(world.provider.getDimension())) {
		DimensionManager.getInstance().getDimensionProperties(world.provider.getDimension()).removeBeaconLocation(world,new HashedBlockPosition(pos));
	}
	super.breakBlock(world, pos, state);
}
 
Example 29
Source Project: BigReactors   Source File: BlockReactorRedstonePort.java    License: MIT License 5 votes vote down vote up
/**
 * A randomly called display update to be able to add particles or other items for display
 */
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random par5Random)
{
	TileEntity te = world.getTileEntity(x, y, z);
    if (te instanceof TileEntityReactorRedstonePort)
    {
    	TileEntityReactorRedstonePort port = (TileEntityReactorRedstonePort)te;
    	if(port.isRedstoneActive()) {
            ForgeDirection out = port.getOutwardsDir();
            
            if(out != ForgeDirection.UNKNOWN) {
                double particleX, particleY, particleZ;
                particleY = y + 0.45D + par5Random.nextFloat() * 0.1D;

                if(out.offsetX > 0)
                	particleX = x + par5Random.nextFloat() * 0.1D + 1.1D;
                else
                	particleX = x + 0.45D + par5Random.nextFloat() * 0.1D;
                
                if(out.offsetZ > 0)
                	particleZ = z + par5Random.nextFloat() * 0.1D + 1.1D;
                else
                	particleZ = z + 0.45D + par5Random.nextFloat() * 0.1D;

                world.spawnParticle("reddust", particleX, particleY, particleZ, 0.0D, par5Random.nextFloat() * 0.1D, 0.0D);
            }
    	}
    }
}
 
Example 30
public void drawBlockDamageTexture(Minecraft mc, Tessellator tessellator, Entity viewEntity, float partialTicks, List<BlockPos> blocksToRender, int partialBlockDamage) {
    double d3 = viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * partialTicks;
    double d4 = viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * partialTicks;
    double d5 = viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks;
    BufferBuilder bufferBuilder = tessellator.getBuffer();
    BlockRendererDispatcher rendererDispatcher = mc.getBlockRendererDispatcher();

    mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    preRenderDamagedBlocks();
    bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    bufferBuilder.setTranslation(-d3, -d4, -d5);
    bufferBuilder.noColor();

    for (BlockPos blockPos : blocksToRender) {
        IBlockState blockState = mc.world.getBlockState(blockPos);
        TileEntity tileEntity = mc.world.getTileEntity(blockPos);
        boolean hasBreak = tileEntity != null && tileEntity.canRenderBreaking();
        if (!hasBreak && blockState.getMaterial() != Material.AIR) {
            TextureAtlasSprite textureAtlasSprite = this.destroyBlockIcons[partialBlockDamage];
            rendererDispatcher.renderBlockDamage(blockState, blockPos, textureAtlasSprite, mc.world);
        }
    }

    tessellator.draw();
    bufferBuilder.setTranslation(0.0D, 0.0D, 0.0D);
    postRenderDamagedBlocks();
}