Everything posted by Dustpuppy
-
[1.10.2] Tank will not keep data when harvested
Sorry, that i am not fit in everything. I've started coding in Java just 5 weeks ago.
-
[1.10.2] Tank will not keep data when harvested
Yes, running in debug mode. Breakpoint again without result (not breaking).
-
[1.10.2] Tank will not keep data when harvested
Ok, debugger and me are not best friends, but as i see, it will not get into it. Have a break point at the first line of ItemBlock.setTileEntityNBT and it will not stop
-
[1.10.2] Tank will not keep data when harvested
OK, command back. The renderer works again. No idea, why he stucks. But the tank still will loose the data, when harvested.
-
[1.10.2] Tank will not keep data when harvested
The special renderer. Like it was before, it was rendering the filling of the tank. Now it's not showing it anymore.
-
[1.10.2] Tank will not keep data when harvested
Block class package thewizardmod.fluids; import java.util.ArrayList; import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; 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.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import thewizardmod.Util.CapabilityUtils; import com.google.common.collect.Lists; public class BlockTank extends Block{ // implements ITileEntityProvider{ public BlockTank() { super(Material.GLASS); this.setCreativeTab(CreativeTabs.MISC); } @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.TRANSLUCENT; } @Override public boolean isOpaqueCube(IBlockState iBlockState) { return false; } @Override public boolean isFullCube(IBlockState iBlockState) { return false; } @Override public EnumBlockRenderType getRenderType(IBlockState iBlockState) { return EnumBlockRenderType.MODEL; } @Override public boolean hasTileEntity() { return true; } private IFluidHandler getFluidHandler(IBlockAccess world, BlockPos pos) { return CapabilityUtils.getCapability(world.getTileEntity(pos), CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { final IFluidHandler fluidHandler = getFluidHandler(worldIn, pos); if (fluidHandler != null) { if(heldItem != null) { // If the bucket is not empty or filled with liquid magic, we don't want it if (heldItem.getItem().equals(Items.BUCKET) || FluidUtil.getFluidContained(heldItem).isFluidEqual(new FluidStack(StartupCommon.fluidMagic, 1000))) { // Try fill/empty the held fluid container from the tank boolean success = FluidUtil.interactWithFluidHandler(heldItem, fluidHandler, playerIn); //If the held item is a fluid container, stop processing here so it doesn't try to place its contents return FluidUtil.getFluidHandler(heldItem) != null; } } } return false; } /* @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityTank(); } */ @Override public boolean hasTileEntity(IBlockState state) { return true; } @Override public TileEntity createTileEntity(World world, IBlockState state) { return new TileEntityTank(); } @Override public final ArrayList<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { int meta = state.getBlock().getMetaFromState(state); ItemStack ret = new ItemStack(this, 1, meta); NBTTagCompound compound = new NBTTagCompound(); TileEntityTank tileEntity = (TileEntityTank) world.getTileEntity(pos); NBTTagCompound tileEntityTag = new NBTTagCompound(); tileEntity.writeToNBT(tileEntityTag); compound.setTag("BlockEntityTag", tileEntityTag); ret.setTagCompound(compound); return Lists.newArrayList(ret); } @Override public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) { if (willHarvest) return true; return super.removedByPlayer(state, world, pos, player, willHarvest); } @Override public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity tileEntity, ItemStack tool) { super.harvestBlock(world, player, pos, state, tileEntity, tool); world.setBlockToAir(pos); } } This works, but the renderer is not working anymore now. The tank it self take the fluid and i can take it out with an empty bucket.
-
[1.10.2] Tank will not keep data when harvested
Now the renderer is not working anymore. Was working before perfekt. I've fighted this beast the half day to get it working. Renderer Class package thewizardmod.fluids; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; import org.lwjgl.opengl.GL11; import thewizardmod.Util.CapabilityUtils; public class RendererTank extends TileEntitySpecialRenderer<TileEntityTank>{ @Override public void renderTileEntityAt(TileEntityTank te, double x, double y, double z, float partialTicks, int destroyStage) { World world = Minecraft.getMinecraft().theWorld; final IFluidHandler fluidHandler = getFluidHandler(world, new BlockPos(te.getPos().getX(), te.getPos().getY(), te.getPos().getZ())); int capacity = fluidHandler.getTankProperties()[0].getCapacity(); FluidStack fluid = fluidHandler.getTankProperties()[0].getContents(); if (fluid != null) { GlStateManager.pushMatrix(); GlStateManager.disableLighting(); GlStateManager.disableCull(); Tessellator tess = Tessellator.getInstance(); VertexBuffer buffer = tess.getBuffer(); buffer.setTranslation(x, y, z); bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); TextureAtlasSprite still = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(fluid.getFluid().getStill().toString()); TextureAtlasSprite flow = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(fluid.getFluid().getFlowing().toString()); double posY = 0.0625F + (0.9 * ((float) fluid.amount / (float) capacity)); float[] color = {1, 0, 0.3f, 0.3f}; float low = 0.0625F; float high = 0.0625F * 15; buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); buffer.pos( low, 1F/16F, high).tex(still.getInterpolatedU(12), still.getInterpolatedV(15)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( high, 1F/16F, high).tex(still.getInterpolatedU( 4), still.getInterpolatedV(15)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( high, posY, high).tex(still.getInterpolatedU( 4), still.getInterpolatedV( 1)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( low, posY, high).tex(still.getInterpolatedU(12), still.getInterpolatedV( 1)).color(color[0], color[1], color[2], color[3]).endVertex(); tess.draw(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); buffer.pos( low, 1F/16F, low).tex(still.getInterpolatedU(12), still.getInterpolatedV(15)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( low, posY, low).tex(still.getInterpolatedU(12), still.getInterpolatedV( 1)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( high, posY, low).tex(still.getInterpolatedU( 4), still.getInterpolatedV( 1)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( high, 1F/16F, low).tex(still.getInterpolatedU( 4), still.getInterpolatedV(15)).color(color[0], color[1], color[2], color[3]).endVertex(); tess.draw(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); buffer.pos( low, posY, low).tex(still.getInterpolatedU(12), still.getInterpolatedV( 1)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( low, posY, high).tex(still.getInterpolatedU(12), still.getInterpolatedV( 1)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( high, posY, high).tex(still.getInterpolatedU( 4), still.getInterpolatedV( 1)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( high, posY, low).tex(still.getInterpolatedU( 4), still.getInterpolatedV( 1)).color(color[0], color[1], color[2], color[3]).endVertex(); tess.draw(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); buffer.pos( low, 1F/16F, low).tex(still.getInterpolatedU(12), still.getInterpolatedV(15)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( high, 1F/16F, low).tex(still.getInterpolatedU( 4), still.getInterpolatedV(15)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( high, 1F/16F, high).tex(still.getInterpolatedU( 4), still.getInterpolatedV(15)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( low, 1F/16F, high).tex(still.getInterpolatedU(12), still.getInterpolatedV(15)).color(color[0], color[1], color[2], color[3]).endVertex(); tess.draw(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); buffer.pos( high, 1F/16F, low).tex(still.getInterpolatedU( 4), still.getInterpolatedV(15)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( high, posY, low).tex(still.getInterpolatedU( 4), still.getInterpolatedV( 1)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( high, posY, high).tex(still.getInterpolatedU( 4), still.getInterpolatedV( 1)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( high, 1F/16F, high).tex(still.getInterpolatedU( 4), still.getInterpolatedV(15)).color(color[0], color[1], color[2], color[3]).endVertex(); tess.draw(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); buffer.pos( low, 1F/16F, low).tex(still.getInterpolatedU(12), still.getInterpolatedV(15)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( low, 1F/16F, high).tex(still.getInterpolatedU(12), still.getInterpolatedV(15)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( low, posY, high).tex(still.getInterpolatedU(12), still.getInterpolatedV( 1)).color(color[0], color[1], color[2], color[3]).endVertex(); buffer.pos( low, posY, low).tex(still.getInterpolatedU(12), still.getInterpolatedV( 1)).color(color[0], color[1], color[2], color[3]).endVertex(); tess.draw(); buffer.setTranslation(0, 0, 0); GlStateManager.popMatrix(); } } private IFluidHandler getFluidHandler(IBlockAccess world, BlockPos pos) { return CapabilityUtils.getCapability(world.getTileEntity(pos), CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null); } }
-
[1.10.2] Tank will not keep data when harvested
If i remove it, what's the replacement? Just removing will cause the tank not working anymore.
-
[1.10.2] Tank will not keep data when harvested
Why not using ITileEntityProvider?
-
[1.10.2] Tank will not keep data when harvested
Hi, i have a tank, that works perfekt, renderer shows right amount, it keeps the data when disconnected and connected again. Just one problem. When i harvest the tank, it will get into my inventory, but it will loose it's data. After replacing, all fluid is gone. Here's the block class. Relevant code, that works on all my other tile entities is at the end of file. package thewizardmod.fluids; import java.util.ArrayList; import javax.annotation.Nullable; import com.google.common.collect.Lists; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; 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.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import thewizardmod.Util.CapabilityUtils; public class BlockTank extends Block implements ITileEntityProvider{ public BlockTank() { super(Material.GLASS); this.setCreativeTab(CreativeTabs.MISC); } @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.TRANSLUCENT; } @Override public boolean isOpaqueCube(IBlockState iBlockState) { return false; } @Override public boolean isFullCube(IBlockState iBlockState) { return false; } @Override public EnumBlockRenderType getRenderType(IBlockState iBlockState) { return EnumBlockRenderType.MODEL; } @Override public boolean hasTileEntity() { return true; } private IFluidHandler getFluidHandler(IBlockAccess world, BlockPos pos) { return CapabilityUtils.getCapability(world.getTileEntity(pos), CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { final IFluidHandler fluidHandler = getFluidHandler(worldIn, pos); if (fluidHandler != null) { if(heldItem != null) { // If the bucket is not empty or filled with liquid magic, we don't want it if (heldItem.getItem().equals(Items.BUCKET) || FluidUtil.getFluidContained(heldItem).isFluidEqual(new FluidStack(StartupCommon.fluidMagic, 1000))) { // Try fill/empty the held fluid container from the tank boolean success = FluidUtil.interactWithFluidHandler(heldItem, fluidHandler, playerIn); //If the held item is a fluid container, stop processing here so it doesn't try to place its contents return FluidUtil.getFluidHandler(heldItem) != null; } } } return false; } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityTank(); } @Override public final ArrayList<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { int meta = state.getBlock().getMetaFromState(state); ItemStack ret = new ItemStack(this, 1, meta); NBTTagCompound compound = new NBTTagCompound(); TileEntityTank tileEntity = (TileEntityTank) world.getTileEntity(pos); NBTTagCompound tileEntityTag = new NBTTagCompound(); tileEntity.writeToNBT(tileEntityTag); compound.setTag("BlockEntityTag", tileEntityTag); ret.setTagCompound(compound); return Lists.newArrayList(ret); } @Override public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) { if (willHarvest) return true; return super.removedByPlayer(state, world, pos, player, willHarvest); } @Override public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity tileEntity, ItemStack tool) { super.harvestBlock(world, player, pos, state, tileEntity, tool); world.setBlockToAir(pos); } }
-
Teleporter working in creative, but not in survival. (1.10.2)
They are working now. It is a fun mod, i hope. That's how it look like when crafting a mirror on the magic altar.
-
Teleporter working in creative, but not in survival. (1.10.2)
I do it, but you know the playing kids. If they find out, that it is possible to put two mirrors to near to each other, they will do. So, i make an if statement, to prevent this.
-
Teleporter working in creative, but not in survival. (1.10.2)
I do. If the second mirror then is near enough to split the player into it, he bounce that fast, that he will hang between both and the console will be flooded with warnings about wrongly moving. I have to check, that gamers will not place the mirrors without a big enough gap between.
-
Teleporter working in creative, but not in survival. (1.10.2)
Ok, this will work now. Just if both blocks are to near and player get bounced between them, i am in trouble. if(worldIn.isRemote) if (entityIn instanceof EntityPlayer) { // should be an EntityPlayerMP; check first just to be sure to avoid crash EntityPlayer entityPlayer = (EntityPlayer)entityIn; entityPlayer.setPositionAndRotation(x, y, z, entityPlayer.rotationYaw, entityPlayer.rotationPitch); } Have taken out the sounds, because they where confusing me. Will put in later on again.
-
Teleporter working in creative, but not in survival. (1.10.2)
The exact same code works without any problems with a right click result of an item. Just within block collision it will not work.
-
Teleporter working in creative, but not in survival. (1.10.2)
Allways the same result.
-
Teleporter working in creative, but not in survival. (1.10.2)
if (entityIn instanceof EntityPlayerMP) { // should be an EntityPlayerMP; check first just to be sure to avoid crash EntityPlayerMP entityPlayerMP = (EntityPlayerMP)entityIn; entityPlayerMP.connection.setPlayerLocation(x, y, z, entityPlayerMP.rotationYaw, entityPlayerMP.rotationPitch); final EntityPlayerMP dontPlayForThisPlayer = entityPlayerMP;
-
Teleporter working in creative, but not in survival. (1.10.2)
I tried every way now. Just on client side, just on server side and on both sides.
-
Teleporter working in creative, but not in survival. (1.10.2)
Hi, i have a problem with my teleporter. It's an item, that places a block and if clicked on a nother block of same type it will bound both together and teleport the player if he collides with one of them. Easy said: 2 mirrors, that will be bound together and teleport the player between both. It's working in creative mode, but in survival mode i allways get : Player moved wrongly! This is the item package thewizardmod.mirror; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; import thewizardmod.Util.RayTrace; public class ItemMirror extends Item { public ItemMirror() { final int MAXIMUM_NUMBER_IN_STACK = 1; this.setMaxStackSize(MAXIMUM_NUMBER_IN_STACK); this.setCreativeTab(CreativeTabs.MISC); // the item will appear on the Miscellaneous tab in creative } @Override public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { RayTraceResult p = RayTrace.rayTraceBlocksAndEntities(worldIn, 5, playerIn); BlockPos newpos; if(p != null) { newpos = p.getBlockPos().offset(facing); if(worldIn.getBlockState(p.getBlockPos()).getBlock() != StartupCommon.mirror) { if(facing == EnumFacing.NORTH || facing == EnumFacing.SOUTH || facing == EnumFacing.WEST || facing == EnumFacing.EAST) { worldIn.setBlockState(newpos, StartupCommon.mirror.getDefaultState().withProperty(Mirror.PROPERTYFACING, facing.getOpposite())); NBTTagCompound nbtTagCompound = stack.getTagCompound(); if (nbtTagCompound != null && nbtTagCompound.hasKey("Bound") && nbtTagCompound.getBoolean("Bound") == true ) { TileEntity tileEntity = worldIn.getTileEntity(newpos); if (tileEntity instanceof TileEntityBlockMirror) { TileEntityBlockMirror te = (TileEntityBlockMirror) tileEntity; double x = nbtTagCompound.getDouble("X"); double y = nbtTagCompound.getDouble("Y"); double z = nbtTagCompound.getDouble("Z"); te.setPosition(x, y, z); double oldX = nbtTagCompound.getDouble("oldTeX"); double oldY = nbtTagCompound.getDouble("oldTeY"); double oldZ = nbtTagCompound.getDouble("oldTeZ"); BlockPos oldTePos = new BlockPos(oldX, oldY, oldZ); TileEntity tileEntityOld = worldIn.getTileEntity(oldTePos); if (tileEntity instanceof TileEntityBlockMirror) { TileEntityBlockMirror te2 = (TileEntityBlockMirror) tileEntityOld; BlockPos targetPos = newpos.offset(facing); te2.setPosition(targetPos.getX(), targetPos.getY(), targetPos.getZ()); } } } stack.stackSize--; } } else { NBTTagCompound nbt; if (stack.hasTagCompound()) { nbt = stack.getTagCompound(); } else { nbt = new NBTTagCompound(); } BlockPos targetPos = newpos.offset(facing); nbt.setBoolean("Bound", true); nbt.setDouble("X", targetPos.getX()); nbt.setDouble("Y", targetPos.getY()); nbt.setDouble("Z", targetPos.getZ()); nbt.setDouble("oldTeX", p.getBlockPos().getX()); nbt.setDouble("oldTeY", p.getBlockPos().getY()); nbt.setDouble("oldTeZ", p.getBlockPos().getZ()); stack.setTagCompound(nbt); if (worldIn.isRemote) { // only on the client side, else you will get two messages.. playerIn.addChatComponentMessage(new TextComponentString("Mirror bound!")); } } } return super.onItemUse(stack, playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ); } } The Block package thewizardmod.mirror; import java.util.List; import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.block.BlockPistonBase; import net.minecraft.block.ITileEntityProvider; 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.EntityPlayerMP; import net.minecraft.init.SoundEvents; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class Mirror extends Block implements ITileEntityProvider{ private static final AxisAlignedBB BOUNCING_BOX_SOUTH = new AxisAlignedBB(0.0625 * 0, 0, 0.0625 * 14, 0.0625 * 16, 0.0625 * 16, 0.0625 * 16); private static final AxisAlignedBB BOUNCING_BOX_NORTH = new AxisAlignedBB(0.0625 * 0, 0, 0.0625 * 0, 0.0625 * 16, 0.0625 * 16, 0.0625 * 2); private static final AxisAlignedBB BOUNCING_BOX_EAST = new AxisAlignedBB(0.0625 * 14, 0, 0.0625 * 0, 0.0625 * 16, 0.0625 * 16, 0.0625 * 16); private static final AxisAlignedBB BOUNCING_BOX_WEST = new AxisAlignedBB(0.0625 * 0, 0, 0.0625 * 0, 0.0625 * 2, 0.0625 * 16, 0.0625 * 16); public static final PropertyDirection PROPERTYFACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public static EnumFacing FACING; public Mirror() { super(Material.GLASS); this.setCreativeTab(CreativeTabs.MISC); this.setDefaultState(this.blockState.getBaseState().withProperty(PROPERTYFACING, EnumFacing.NORTH)); setHardness(3.0F); setResistance(5.0F); } @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.TRANSLUCENT; } @Override public boolean isOpaqueCube(IBlockState iBlockState) { return false; } @Override public boolean isFullCube(IBlockState iBlockState) { return false; } @Override public EnumBlockRenderType getRenderType(IBlockState iBlockState) { return EnumBlockRenderType.MODEL; } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityBlockMirror(); } @Override @Deprecated public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { if(state.getValue(PROPERTYFACING) == EnumFacing.NORTH) { return BOUNCING_BOX_NORTH; } if(state.getValue(PROPERTYFACING) == EnumFacing.SOUTH) { return BOUNCING_BOX_SOUTH; } if(state.getValue(PROPERTYFACING) == EnumFacing.EAST) { return BOUNCING_BOX_EAST; } if(state.getValue(PROPERTYFACING) == EnumFacing.WEST) { return BOUNCING_BOX_WEST; } return null; } @Override public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing blockFaceClickedOn, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { // find the quadrant the player is facing EnumFacing enumfacing = (placer == null) ? EnumFacing.NORTH : EnumFacing.fromAngle(placer.rotationYaw); FACING = enumfacing; TileEntity tileEntity = worldIn.getTileEntity(pos); if (tileEntity instanceof TileEntityBlockMirror) { int facing = MathHelper.floor_double((double) ((placer.rotationYaw * 4F) / 360F) + 0.5D) & 3; ((TileEntityBlockMirror) tileEntity).setFacing(facing); } return this.getDefaultState().withProperty(PROPERTYFACING, enumfacing); } @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { return state; } @Override public IBlockState getStateFromMeta(int meta) { return getDefaultState().withProperty(PROPERTYFACING, EnumFacing.getHorizontal(meta)); } @Override public int getMetaFromState(IBlockState state) { return state.getValue(PROPERTYFACING).getHorizontalIndex(); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {PROPERTYFACING}); } @Override public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) { TileEntity tileEntity = worldIn.getTileEntity(pos); if (tileEntity instanceof TileEntityBlockMirror) { TileEntityBlockMirror te = (TileEntityBlockMirror) tileEntity; double x = te.getX(); double y = te.getY(); double z = te.getZ(); if (worldIn.isRemote) { // client side worldIn.playSound(x, y, z, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F, false); } else { // server side if (entityIn instanceof EntityPlayerMP) { // should be an EntityPlayerMP; check first just to be sure to avoid crash EntityPlayerMP entityPlayerMP = (EntityPlayerMP)entityIn; entityPlayerMP.connection.setPlayerLocation(x, y, z, entityPlayerMP.rotationYaw, entityPlayerMP.rotationPitch); final EntityPlayerMP dontPlayForThisPlayer = entityPlayerMP; worldIn.playSound(dontPlayForThisPlayer, x, y, z, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F); } } } super.onEntityCollidedWithBlock(worldIn, pos, state, entityIn); } } And the tile entity package thewizardmod.mirror; import javax.annotation.Nullable; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.texture.ITickable; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import thewizardmod.items.StartupCommon; public class TileEntityBlockMirror extends TileEntity{ public int facing; public double posX, posY, posZ; public int getFacing() { return facing; } public void setFacing(int facing) { this.facing = facing; markDirty(); } public void setPosition(double x, double y, double z) { this.posX = x; this.posY = y; this.posZ = z; markDirty(); } public double getX() { return posX; } public double getY() { return posY; } public double getZ() { return posZ; } @Override public NBTTagCompound writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); tag.setInteger("facing", facing); tag.setDouble("X", posX); tag.setDouble("Y", posY); tag.setDouble("Z", posZ); return tag; } @Override public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); this.facing = tag.getInteger("facing"); this.posX = tag.getDouble("X"); this.posY = tag.getDouble("Y"); this.posZ = tag.getDouble("Z"); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { NBTTagCompound tag = pkt.getNbtCompound(); this.facing = tag.getInteger("facing"); this.posX = tag.getDouble("X"); this.posY = tag.getDouble("Y"); this.posZ = tag.getDouble("Z"); } @Override @Nullable public SPacketUpdateTileEntity getUpdatePacket() { NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("facing", facing); tag.setDouble("X", posX); tag.setDouble("Y", posY); tag.setDouble("Z", posZ); return new SPacketUpdateTileEntity(pos, getBlockMetadata(), tag); } @Override public NBTTagCompound getUpdateTag() { NBTTagCompound tag = super.getUpdateTag(); tag.setInteger("facing", facing); tag.setDouble("X", posX); tag.setDouble("Y", posY); tag.setDouble("Z", posZ); return tag; } } Possible something simple in the teleportation, i can't see.
-
Render with reflection like a mirror possible? (1.10.2)
Hello again, i have a teleporting system over mirrors player can bound together and place. The mirrors just looking horrible. Is it possible to render a plane, that has a reflection, like a real mirror, that player will see him self when standing in front? If it is too much, i will use normal textures, but a real mirror would be great.
-
1.10 using EnumFacing with all 6 directions
PROPERTYFACING is set like so public static final PropertyDirection PROPERTYFACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); And you need a json in blockstates, that has poperties facing and 6 models in block, one for each side.
-
1.10 using EnumFacing with all 6 directions
I solved it this way on block placing Horizontal placing, like furnace. @Override public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing blockFaceClickedOn, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { // find the quadrant the player is facing EnumFacing enumfacing = (placer == null) ? EnumFacing.NORTH : EnumFacing.fromAngle(placer.rotationYaw); // Place allways same up and down direction return this.getDefaultState().withProperty(PROPERTYFACING, enumfacing); } And every direction placing, like piston @Override public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing blockFaceClickedOn, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { return this.getDefaultState().withProperty(PROPERTYFACING, BlockPistonBase.getFacingFromEntity(pos, placer)); }
-
Magic Mod - running out of ideas
Some picture of what i have and what's going on.
-
Magic Mod - running out of ideas
Hi, i am making a magic mod and now i am running out of ideas. What i have : A custom ore that drops a dust called shadow dust. It's used for all kind of magic. A machine called magic injector. It's used to inject magic into wands and some other items. 4 different wands. Wooden, iron and golden ones that can made in a crafting table. A blaze wand is made with a magic altar, only if you allready have an iron wand. Wands can have different amounts of magic injected, have different recharge speed and amount of usage before they need to reload. Injectable magics are Flamethrower, Lightning bolt, light, growing vines for climbing, short distance teleporter, growth like bonemeal, spawn cob webs, mining and ice water. Diamonds can be injected with magic to gems used for other things, like long distance teleporter. A jar, that at the moment can only take a heart of an undead (rearly droped by custom zombie mob) . The heart will bump and as faster it bumps, as more mobs are in 20 block range around it. An altar, that has an main block with 4 pedestrals around. It's used for crafting high tier stuff, like the blaze wand and a magic chest with 9 slots, that will randomly increase his own inventar. A custom dimension, that looks like the overworld, but with lakes out of poison liquid and a structure, i want to expand to a dungeon under earth. Iron can be injected with magic for tools (something between iron and diamond) and a full set of armor. Strings can be injected with magic to magic string, that's used to make a robe. Armor and robe will ingrease the durabillity and power of wands and rise the chances of altar crafting and lower the misscrafting on an altar. The portal to the custom dimension can only be activated with golden or blaze wand. A glas injected with magic will take the texture of blocks beside, when placed, but you can walk through. Rune stones that can be arranged around the altar to ingrease the chances of getting increments back and reduce the problem, that sometimes no magic happens, but increment are gone. There are 24 different runes that can be crafted on the altar and then combined (clicked on) the rune stones. Every rune also changes behavor of the altar, depending on what kind of rune it is. Each rne has differend recipe. Now i am running out of ideas. What can i do next? What do you think is missing?
-
Custom Mob not dropping with loot table (1.10.2)
package thewizardmod.entity; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EnumCreatureType; import net.minecraft.init.Biomes; import net.minecraft.world.storage.loot.LootTableList; import net.minecraftforge.fml.common.registry.EntityRegistry; import thewizardmod.TheWizardMod; public class StartupCommon { private static int entityID = 0; public static void preInitCommon() { int id = 1; EntityRegistry.registerModEntity(EntityWeirdZombie.class, "WeirdZombie", id++, TheWizardMod.instance, 64, 3, true, 0x996600, 0xff00ff); // EntityRegistry.addSpawn(EntityWeirdZombie.class, 100, 3, 5, EnumCreatureType.MONSTER, Biomes.PLAINS, Biomes.ICE_PLAINS); LootTableList.register(EntityWeirdZombie.deathLootTable); } public static void initCommon() { } public static void postInitCommon() { } } It's registered. I've commend out the spawn, because i only spawn them in my custom dimension.
IPS spam blocked by CleanTalk.