Jump to content

Schauweg

Members
  • Posts

    8
  • Joined

  • Last visited

Schauweg's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I want to get the offers of the villagers on the client. I assume I can only get them when the player is opening the GUI of a villager but I still can't figure it out. @SubscribeEvent public void onGuiOpen(GuiOpenEvent event){ if (event.getGui() instanceof MerchantScreen){ MerchantScreen gui = (MerchantScreen) event.getGui(); MerchantContainer container = gui.getContainer(); System.out.println(container.getOffers()); } } Using this code I get an empty MerchantOffers object. Maybe someone knows a solution to this problem.
  2. Thank you so much! I've struggled with this issue for far too long I'm okay with to admit...
  3. So I have this problem with my custom Nametag. Some stuff is invisible behind it like chests and coloured glass as seen in the picture. I also think thats related to this bug since I use the RenderNameplateEvent Here is my code @SubscribeEvent public void onNameplateRender(RenderNameplateEvent event){ if (event.getEntity() instanceof TNTEntity && event.getEntity() != null){ TNTEntity entity = (TNTEntity)(event.getEntity()); EntityRendererManager manager = Minecraft.getInstance().getRenderManager(); IRenderTypeBuffer renderTypeBuffer = event.getRenderTypeBuffer(); renderTag(manager, entity, ticksToTime(entity.getFuse()), event.getMatrixStack(), renderTypeBuffer); } } @SuppressWarnings("rawtypes") private void renderTag(EntityRendererManager manager, Entity entity, String text, MatrixStack stack, IRenderTypeBuffer impl) { float height = entity.getHeight(); stack.push(); stack.translate(0.0D, height + 0.5F, 0.0D); stack.rotate(manager.getCameraOrientation()); stack.scale(-0.025F, -0.025F, 0.025F); Matrix4f matrix4f = stack.getLast().getMatrix(); FontRenderer fontRenderer = manager.getFontRenderer(); float offset = (float)(-fontRenderer.getStringWidth(text) / 2); fontRenderer.renderString(text, offset, 0F, 553648127, false, matrix4f, impl, true, 1056964608, 15728640); fontRenderer.renderString(text, offset, 0F, -1, false, matrix4f, impl, false, 1056964608, 15728640); stack.pop(); } private String ticksToTime(int ticks){ if(ticks > 20*3600){ int h = ticks/20/3600; return h+" h"; } else if(ticks > 20*60){ int m = ticks/20/60; return m+" m"; } else { int s = ticks / 20; int ms = (ticks % 20) / 2; return s+"."+ms+" s"; } } Do you maybe have an idea to get around this issue?
  4. Hi, I already asked on a Discord Server how to do it and they told me to override the isFullCube boolean and return it with false, but I already did this because my block is not a full block in the first place. But it's still not working. This is the code for this block. package com.schauweg.kruscht.objects.blocks; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; public class BlockCorrugatedIron extends HorizontalBase { protected static final AxisAlignedBB BOUNDING_BOX = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.1875D, 1.0D); public BlockCorrugatedIron(String name, Material material) { super(name, material); setSoundType(SoundType.METAL); setHardness(1F); setResistance(15F); setHarvestLevel("pickaxe", 2); } @Override public boolean isFullCube(IBlockState state) { return false; } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return BOUNDING_BOX; } }
  5. Hi, I have a problem with my End Rod like block and its facing when I'm placing it. The difference between like a piston placing behavior and the end rod one is, that it doens't matter which way you're facing, but instead what side of a block you're aiming. I looked at the End Rod block and tried to copy it's code and adapt it to my block, but it doesn't really work. Every time I place the block it's just upside down, whether I aim at the top side of a block or not. When I place my block with the /setblock command and rotate it that way, everything, like the hitbox and model is fine. This is my block code: package com.schauweg.kruscht.objects.blocks; import com.schauweg.kruscht.init.BlockInit; import net.minecraft.block.SoundType; 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.entity.EntityLivingBase; import net.minecraft.util.*; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import java.util.Random; public class BlockBlazeRod extends BlockBase { public static final PropertyDirection FACING = PropertyDirection.create("facing"); public static final AxisAlignedBB BLAZE_ROD_VERTICAL_AABB = new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.0D, 0.625D); public static final AxisAlignedBB BLAZE_ROD_NS_AABB = new AxisAlignedBB(0.375D, 0.375D, 0.0D, 0.625D, 0.625D, 1.0D); public static final AxisAlignedBB BLAZE_ROD_EW_AABB = new AxisAlignedBB(0.0D, 0.375D, 0.375D, 1.0D, 0.625D, 0.625D); public BlockBlazeRod(String name, Material material) { super(name, material); setSoundType(SoundType.WOOD); setHarvestLevel("axe", 0); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.UP)); } public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); } public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withProperty(FACING, mirrorIn.mirror((EnumFacing)state.getValue(FACING))); } public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { switch (((EnumFacing)state.getValue(FACING)).getAxis()) { case X: default: return BLAZE_ROD_EW_AABB; case Z: return BLAZE_ROD_NS_AABB; case Y: return BLAZE_ROD_VERTICAL_AABB; } } public boolean isOpaqueCube(IBlockState state) { return false; } public boolean isFullCube(IBlockState state) { return false; } public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { return true; } public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { IBlockState iblockstate = worldIn.getBlockState(pos.offset(facing.getOpposite())); if (iblockstate.getBlock() == BlockInit.BLOCK_BLAZE_ROD) { EnumFacing enumfacing = (EnumFacing)iblockstate.getValue(FACING); if (enumfacing == facing) { return this.getDefaultState().withProperty(FACING, facing.getOpposite()); } } return this.getDefaultState().withProperty(FACING, facing); } public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { EnumFacing enumfacing = (EnumFacing)stateIn.getValue(FACING); double d0 = (double)pos.getX() + 0.55D - (double)(rand.nextFloat() * 0.1F); double d1 = (double)pos.getY() + 0.55D - (double)(rand.nextFloat() * 0.1F); double d2 = (double)pos.getZ() + 0.55D - (double)(rand.nextFloat() * 0.1F); double d3 = (double)(0.4F - (rand.nextFloat() + rand.nextFloat()) * 0.4F); if (rand.nextInt(5) == 0) { worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + (double)enumfacing.getFrontOffsetX() * d3, d1 + (double)enumfacing.getFrontOffsetY() * d3, d2 + (double)enumfacing.getFrontOffsetZ() * d3, rand.nextGaussian() * 0.005D, rand.nextGaussian() * 0.005D, rand.nextGaussian() * 0.005D); } } public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; } public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = this.getDefaultState(); iblockstate = iblockstate.withProperty(FACING, EnumFacing.getFront(meta)); return iblockstate; } public int getMetaFromState(IBlockState state) { return ((EnumFacing)state.getValue(FACING)).getIndex(); } protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {FACING}); } } This is my BlockBase code: package com.schauweg.kruscht.objects.blocks; import com.schauweg.kruscht.Main; import com.schauweg.kruscht.init.BlockInit; import com.schauweg.kruscht.init.ItemInit; import com.schauweg.kruscht.util.IHasModel; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; public class BlockBase extends Block implements IHasModel { public BlockBase(String name, Material material) { super(material); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(Main.KRUSCHTTAB); BlockInit.BLOCKS.add(this); ItemInit.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName())); } @Override public void registerModels() { Main.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory"); } } This is the the End Rod Block code: [Edit: Removed copyrighted code - diesieben07] and finally this is their BlockDirectional code: package net.minecraft.block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyDirection; public abstract class BlockDirectional extends Block { public static final PropertyDirection FACING = PropertyDirection.create("facing"); protected BlockDirectional(Material materialIn) { super(materialIn); } } Hopefully someone can help me.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.