Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

NErOHUN

Members
  • Posts

    3
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

NErOHUN's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hi all! I need some help with TileEntity. I made a block which teleports the player to an adjusted position when the player walks on it. My problem is that the TileEntity saves the datas (coordinates, dimension etc.) with the NBTTag, and loads them, but for some reason the variables are empty after I re-enter to the world. As you can see in the code, I'm writing out the x coordinate. The problem: I set the blocks destination, the block works perfectly, teleports the player. When I pause the game, it saves the NBT tag, because I can read the x position from the console. I left the world, and re-enter to it. Then I can see the coordinate again, so the NBTTag contains it, and it seems to be loaded. But the block isn't working, and if I pause the game again, it saves 0 as x position (and as the others). Does anyone have any ideas? I have some other block whichs code looks like this, and they're working normally. I wrote the same code when I initialized the block (and the others are working), but I gonna show you that too. TileEntity package Apocalipty.blocks.portal; import java.util.ArrayList; import Apocalipty.entities.friendlies.entity_base_trader; import Apocalipty.entities.zombies.entity_zombie_frozen; import Apocalipty.entities.zombies.entity_zombie_normal; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ITickable; import net.minecraft.util.math.BlockPos; import scala.reflect.internal.Trees.This; public class TileEntityTeleporter extends TileEntity{ private int x = 0; private int y = 0; private int z = 0; private int dim = 0; private boolean enabled = false; @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); if(compound.hasKey("x")) this.x = compound.getInteger("x"); if(compound.hasKey("y")) this.y = compound.getInteger("y"); if(compound.hasKey("z")) this.z = compound.getInteger("z"); if(compound.hasKey("dim")) this.dim = compound.getInteger("dim"); if(compound.hasKey("enabled")) this.enabled = compound.getBoolean("enabled"); System.out.println(this.x); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger("x", this.x); compound.setInteger("y", this.y); compound.setInteger("z", this.z); compound.setInteger("dim", this.dim); compound.setBoolean("enabled", this.enabled); System.out.println(this.x); return compound; } public void setCoord(int x, int y, int z, int dim) { this.x = x; this.y = y; this.z = z; this.dim = dim; this.enabled = true; } public BlockPos getTeleportPos() { return new BlockPos(this.x, this.y, this.z); } public Integer getDimension() { return this.dim; } public boolean getEnabled() { return this.enabled; } } Block package Apocalipty.blocks.portal; import java.util.Random; import Apocalipty.Main; import Apocalipty.handlers.LootHandler; import Apocalipty.handlers.SoundsHandler; import Apocalipty.init.ItemInit; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.InventoryHelper; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.Mirror; import net.minecraft.util.NonNullList; import net.minecraft.util.Rotation; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class Teleporter extends BlockContainer { public Teleporter(String name, Material material, CreativeTabs tab) { super(material); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(tab); setHardness(40.0f); setHarvestLevel("pickaxe", 2); } @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.SOLID; } @Override public boolean isOpaqueCube(IBlockState iBlockState) { return true; } @Override public boolean isFullCube(IBlockState iBlockState) { return true; } @Override public EnumBlockRenderType getRenderType(IBlockState iBlockState) { return EnumBlockRenderType.MODEL; } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityTeleporter(); } @Override public boolean isFullBlock(IBlockState state) { return false; } @Override public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn) { if(entityIn instanceof EntityPlayer && !worldIn.isRemote) { TileEntityTeleporter tileEntity = (TileEntityTeleporter) worldIn.getTileEntity(pos); EntityPlayer player = (EntityPlayer) entityIn; if(tileEntity.getEnabled()) { int playerDim = player.dimension; int destDim = tileEntity.getDimension(); if(playerDim != destDim) { player.changeDimension(destDim); } BlockPos p = tileEntity.getTeleportPos(); player.setPositionAndUpdate(p.getX(), p.getY(), p.getZ()); } } } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if(!worldIn.isRemote) { ItemStack held = playerIn.getHeldItem(hand); if(held.getItem() == ItemInit.SAVER) { NBTTagCompound compound = null; if(held.getTagCompound() == null) { compound = new NBTTagCompound(); }else { compound = held.getTagCompound(); } if(!compound.hasKey("x")) return true; int x = compound.getInteger("x"); int y = compound.getInteger("y"); int z = compound.getInteger("z"); int dim = compound.getInteger("dim"); TileEntityTeleporter tileEntity = (TileEntityTeleporter) worldIn.getTileEntity(pos); tileEntity.setCoord(x, y, z, dim); Main.sendMessage(playerIn, "COORDS SET!"); } } return true; } } Block Initialization part GameRegistry.registerTileEntity(TileEntityTeleporter.class, Reference.MODID + ":teleporter_tile_entity"); TELEPORTER = new Teleporter("teleporter", Material.ROCK, Main.tab); ForgeRegistries.BLOCKS.register(TELEPORTER); itemTeleporter = new ItemBlock(TELEPORTER); itemTeleporter.setRegistryName(TELEPORTER.getRegistryName()); ForgeRegistries.ITEMS.register(itemTeleporter);
  2. I used the vanilla torch blockstate examples, from here: https://minecraft.gamepedia.com/Model. And then it has texture in my inventory, like an item, but when I place it down, it shows like a block, which has no texture. Here are the errors, and some pictures from the game.
  3. You're right. I made the blockstate and a template to the torch. It has texture like an item (in my hand), but when I place it down, it seems like a block which has no texture. When the game starts, it tries to load the model with facings(EAST, WEST, stc.), like a normal block which has different sides. And of course I get error, because there aren't any facing parameter in the blockstate file. My torch file in the models/item folder { "parent": "modminers:block/napalm" } The blockstate file in the models/block folder { "parent": "modminers:block/torchtemplate", "textures": { "torch": "modminers:blocks/napalm" } } And my torchtemplate file in the models/block folder too { "ambientocclusion": false, "textures": { "particle": "#torch" }, "elements": [ { "from": [ 7, 0, 7 ], "to": [ 9, 10, 9 ], "shade": false, "faces": { "down": { "uv": [ 7, 13, 9, 15 ], "texture": "#torch" }, "up": { "uv": [ 7, 6, 9, 8 ], "texture": "#torch" } } }, { "from": [ 7, 0, 0 ], "to": [ 9, 16, 16 ], "shade": false, "faces": { "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" }, "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" } } }, { "from": [ 0, 0, 7 ], "to": [ 16, 16, 9 ], "shade": false, "faces": { "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" }, "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" } } } ] }
  4. Hi! I want to make a torch in my forge mod (1.12.2). I've already made my "Torch Base" class, and created the torch, which is working, but doesn't have texture. I tried to add the texture, like a simple block, but -of course- it doesn't working. This is in the block's json file. { "parent": "block/cube_all", "textures": { "all": "modminers:blocks/napalm" } } And this is the torch class: public class Napalm extends BlockTorch implements IHasModel { public Napalm(String name, CreativeTabs tab) { super(); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(tab); setLightLevel(100.0F); BlockInit.BLOCKS.add(this); ItemInit.ITEMS.add(new ItemBlock(this).setRegistryName(name)); } @Override public void registerModels() { Main.proxy.registerModel(Item.getItemFromBlock(this), 0); } } I think I have to change something about the texture integration, but I don't know what. I hope I wrote everything down understandable, and thank you in advice for your answers. (PS.: Sorry for my bad English)
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.