net.minecraft.tileentity.TileEntity Java Examples

The following examples show how to use net.minecraft.tileentity.TileEntity. 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 File: TileEntityPassengerChair.java    From Valkyrien-Skies with Apache License 2.0 7 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 #2
Source File: MultiblockTurbineSimulator.java    From reactor_simulator with 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 #3
Source File: TileEntityReactorFuelRodSimulator.java    From reactor_simulator with MIT License 6 votes vote down vote up
@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 #4
Source File: DragonsFuck.java    From ehacks-pro with 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 #5
Source File: StatementManager.java    From Framez with 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 #6
Source File: BigReactorsGUIHandler.java    From BigReactors with 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 #7
Source File: BlockJar.java    From Wizardry with 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 #8
Source File: ItemTofuEnergyContained.java    From TofuCraftReload with 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 #9
Source File: TileEntityDumper.java    From NEI-Integration with 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 #10
Source File: ChiselGuiHandler.java    From Chisel-2 with 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 #11
Source File: BlockQuantumComputer.java    From qcraft-mod with 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 #12
Source File: BW_TileEntityContainer.java    From bartworks with 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 #13
Source File: SchematicTile.java    From Framez with 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 #14
Source File: AdapterWritingDesk.java    From OpenPeripheral-Integration with 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 #15
Source File: SubTileGenerating.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
@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 #16
Source File: BlockEssentiaGenerators.java    From Electro-Magic-Tools with GNU General Public License v3.0 6 votes vote down vote up
@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 #17
Source File: AdjacentInventoryHelper.java    From BigReactors with 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 #18
Source File: BlockSaltFurnace.java    From TofuCraftReload with 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 #19
Source File: BlockBlueprintArchive.java    From Cyberware with 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 #20
Source File: SignTextMod.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onInput(MouseEvent event) {
  if (event.getButton() == 2 && Mouse.getEventButtonState()) { // on middle click
    RayTraceResult result = MC.player.rayTrace(999, 0);
    if (result == null) {
      return;
    }
    if (result.typeOfHit == RayTraceResult.Type.BLOCK) {
      TileEntity tileEntity = MC.world.getTileEntity(result.getBlockPos());
      
      if (tileEntity instanceof TileEntitySign) {
        TileEntitySign sign = (TileEntitySign) tileEntity;
        
        int signTextLength = 0;
        // find the first line from the bottom that isn't empty
        for (int i = 3; i >= 0; i--) {
          if (!sign.signText[i].getUnformattedText().isEmpty()) {
            signTextLength = i + 1;
            break;
          }
        }
        if (signTextLength == 0) {
          return; // if the sign is empty don't do anything
        }
        
        String[] lines = new String[signTextLength];
        
        for (int i = 0; i < signTextLength; i++) {
          lines[i] =
              sign.signText[i].getFormattedText().replace(TextFormatting.RESET.toString(), "");
        }
        
        String fullText = String.join("\n", lines);
        
        Helper.printMessage("Copied sign");
        setClipboardString(fullText);
      }
    }
  }
}
 
Example #21
Source File: MCNetworkState.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onForceModeChanged(MCPos signalPos, EnumForceMode forceStatus){
    super.onForceModeChanged(signalPos, forceStatus);
    TileEntity te = signalPos.getLoadedTileEntity();
    if(te instanceof TileEntitySignalBase) {
        ((TileEntitySignalBase)te).setForceMode(forceStatus);
    }
}
 
Example #22
Source File: MixinTileEntity.java    From VanillaFix with MIT License 5 votes vote down vote up
@Inject(method = "addInfoToCrashReport", at = @At("TAIL"))
private void onAddEntityCrashInfo(CrashReportCategory category, CallbackInfo ci) {
    if (!noNBT) {
        noNBT = true;
        // "Block Entity" to stay consistent with vanilla strings
        category.addDetail("Block Entity NBT", () -> ((TileEntity) (Object) this).writeToNBT(new NBTTagCompound()).toString());
        noNBT = false;
    }
}
 
Example #23
Source File: BlockPassengerChair.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
    TileEntity passengerChair = worldIn.getTileEntity(pos);
    if (passengerChair instanceof TileEntityPassengerChair && !passengerChair.isInvalid()) {
        ((TileEntityPassengerChair) passengerChair).onBlockBroken(state);
    }
    super.breakBlock(worldIn, pos, state);
}
 
Example #24
Source File: ItemMagnifyingGlass.java    From AgriCraft with MIT License 5 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (!world.isRemote) {
        List<String> list = new ArrayList<>();
        IBlockState state = world.getBlockState(pos);
        Block block = state.getBlock();
        TileEntity te = world.getTileEntity(pos);

        // Add a separator.
        list.add("========== " + AgriCore.getTranslator().translate("item.agricraft:magnifying_glass.name") + " ==========");

        // Add lighting information.
        list.add("Brightness: (" + world.getLightFromNeighbors(pos.up()) + "/15)");

        // Add block information.
        if (block instanceof IAgriDisplayable) {
            ((IAgriDisplayable) block).addDisplayInfo(list::add);
        }

        // Add tile information.
        if (te instanceof IAgriDisplayable) {
            ((IAgriDisplayable) te).addDisplayInfo(list::add);
        }

        // Display information.
        for (String msg : list) {
            player.sendMessage(new TextComponentString(msg));
        }
    }
    return EnumActionResult.SUCCESS;
}
 
Example #25
Source File: PneumaticCraftUtils.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public static ItemStack exportStackToInventory(TileEntity te, ItemStack stack, ForgeDirection side){
    if(te instanceof IInventory) {
        return TileEntityHopper.func_145889_a((IInventory)te, stack, side.ordinal());
    } else {
        stack = ModInteractionUtils.getInstance().exportStackToTEPipe(te, stack, side);
        stack = ModInteractionUtils.getInstance().exportStackToBCPipe(te, stack, side);
        return stack;
    }
}
 
Example #26
Source File: CommandsAdmin.java    From MyTown2 with The Unlicense 5 votes vote down vote up
@Command(
        name = "itemClass",
        permission = "mytown.adm.cmd.debug.item",
        parentName = "mytown.adm.cmd.debug",
        syntax = "/townadmin debug itemClass",
        console = false)
public static CommandResponse debugItemCommand(ICommandSender sender, List<String> args) {
    if(sender instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer)sender;
        List<Class> list = new ArrayList<Class>();
        if(player.inventory.getCurrentItem() != null) {

            if(player.inventory.getCurrentItem().getItem() instanceof ItemBlock) {
                Block block = ((ItemBlock)player.inventory.getCurrentItem().getItem()).field_150939_a;
                list.add(block.getClass());
                if(block instanceof ITileEntityProvider) {
                	TileEntity te = ((ITileEntityProvider) block).createNewTileEntity(MinecraftServer.getServer().worldServerForDimension(0), 0);
                    list.add(te == null ? TileEntity.class : te.getClass());
                }
            } else {
                list.add(player.inventory.getCurrentItem().getItem().getClass());
            }

            ChatManager.send(sender, new ChatComponentText("For item: " + player.inventory.getCurrentItem().getDisplayName()));
            for(Class cls : list) {
                while (cls != Object.class) {
                    ChatManager.send(sender, new ChatComponentText(cls.getName()));
                    cls = cls.getSuperclass();
                }
            }
        }
    }
    return CommandResponse.DONE;
}
 
Example #27
Source File: BlockRotationAxle.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
    super.breakBlock(worldIn, pos, state);
    TileEntity tile = worldIn.getTileEntity(pos);
    if (tile != null) {
        tile.invalidate();
    }
}
 
Example #28
Source File: MixinRenderGlobal.java    From VanillaFix with MIT License 5 votes vote down vote up
/**
 * @reason Adds subsections to the "root.gameRenderer.level.entities.blockentities"
 * profiler, using the tile entity ID, or the class name if the id is null.
 */
@Redirect(method = "renderEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher;render(Lnet/minecraft/tileentity/TileEntity;FI)V"))
private void tileEntityRender(TileEntityRendererDispatcher renderDispatcher, TileEntity tileEntity, float partialTicks, int destroyStage) {
    world.profiler.func_194340_a(() -> { // func_194340_a = startSection(Supplier<String>)
        final ResourceLocation tileEntityId = TileEntity.getKey(((TileEntity) tileEntity).getClass());
        return tileEntityId == null ? tileEntity.getClass().getSimpleName() : tileEntityId.toString();
    });
    renderDispatcher.render(tileEntity, partialTicks, destroyStage);
    world.profiler.endSection();
}
 
Example #29
Source File: TileEntitySelectorRenderer.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
	final TileEntitySelector selector = (TileEntitySelector)tileEntity;
	final Orientation orientation = selector.getOrientation();

	GL11.glPushMatrix();
	GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
	TransformProvider.instance.multMatrix(orientation);
	GL11.glTranslated(-0.5, 0.501, -0.5); // 0.001 offset for 2d items in fast mode

	final int gridSize = selector.getGridSize();

	renderer.setRenderManager(RenderManager.instance);

	for (ItemSlot slot : selector.getSlots(gridSize)) {
		ItemStack stack = selector.getSlot(slot.slot);
		if (stack != null) {
			EntityItem display = selector.getDisplayEntity();

			GL11.glPushMatrix();
			GL11.glTranslated(slot.x, 0, slot.y + 0.03); // 0.03, since items are rendered off-center
			GL11.glRotated(-90, 1, 0, 0);
			final double scale = slot.size * 5;
			GL11.glScaled(scale, scale, scale);
			display.setEntityItemStack(stack);
			RenderItem.renderInFrame = true;
			renderer.doRender(display, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
			GL11.glPopMatrix();
		}
	}

	RenderItem.renderInFrame = false;

	GL11.glPopMatrix();
}
 
Example #30
Source File: GTBlockSuperconductorCable.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
	try {
		TileEntity tile = world.getTileEntity(pos);
		if (tile instanceof GTTileBaseSuperconductorCable) {
			GTTileBaseSuperconductorCable wire = (GTTileBaseSuperconductorCable) tile;
			return new BlockStateContainerIC2.IC2BlockState(state, wire.getConnections());
		}
	} catch (Exception exception) {
	}
	return super.getExtendedState(state, world, pos);
}