-
Posts
13 -
Joined
-
Last visited
max2461's Achievements

Tree Puncher (2/8)
0
Reputation
-
It has been a long time since I have modded for Minecraft, and despite my research I cannot find methods to replace the ones I used back in 1.14.4. I know the mappings have changed and everything, so its a bit of a learning curve. _________________________________________________________________________________________________________ Quick 'functionality' summary: _________________________________________________________________________________________________________ [On Item Right Click] If Player is sneaking: - Store Players Position in NBT. - Store Players Dimension ID in NBT. - Changes Item's Display Name + Color Depending on Dimension ID. - Adds Stored Information to Items Tooltip. If Player is not sneaking: If Item has Stored Data & Player is in the same Dimension as the items stored Dimension ID: - Teleport the player to the coordinates stored. - Item 'Breaks' and is replaced with a different item. _________________________________________________________________________________________________________ Old Code _________________________________________________________________________________________________________ @Override public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ){ if(playerIn.isSneaking()){ if(stack.getTagCompound() == null){ stack.setTagCompound(new NBTTagCompound()); } } NBTTagCompound nbt = new NBTTagCompound(); nbt.setInteger("dim", playerIn.dimension); nbt.setInteger("posX", pos.getX()); nbt.setInteger("posY", pos.getY()+1); nbt.setInteger("posZ", pos.getZ()); stack.getTagCompound().setTag("coords", nbt); // TO-DO: Different ChatFormatting for each Dimension stack.setStackDisplayName(EnumChatFormatting.DARK_RED + "Teleport Device"); } return false; } @Override public ItemStack onItemRightClick(ItemStack stack, World worldIn, EntityPlayer playerIn){ if(!playerIn.isSneaking()){ if(stack.getTagCompound() != null){ NBTTagCompound nbt = (NBTTagCompound) stack.getTagCompound().getTag("coords"); int posX = nbt.getInteger("posX"); int posY = nbt.getInteger("posY"); int posZ = nbt.getInteger("posZ"); playerIn.setPosition(posX, posY, posZ); stack.getTagCompound().removeTag("coords"); stack.clearCustomName(); playerIn.addPotionEffect(new PotionEffect(Potion.regeneration.id,30,60)); playerIn.addPotionEffect(new PotionEffect(Potion.blindness.id,90,60)); playerIn.addPotionEffect(new PotionEffect(Potion.confusion.id,90,60)); playerIn.addPotionEffect(new PotionEffect(Potion.resistance.id,50,500)); if(!playerIn.capabilities.isCreativeMode){ playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem,new ItemStack(ModItems.defectiveHistory)); } } } return stack; } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer playerIn, List toolTip, boolean advanced) { if(stack.getTagCompound() != null){ if(stack.getTagCompound().hasKey("coords")){ NBTTagCompound nbt = (NBTTagCompound) stack.getTagCompound().getTag("coords"); int dim = nbt.getInteger("dim"); int posX = nbt.getInteger("posX"); int posY = nbt.getInteger("posY"); int posZ = nbt.getInteger("posZ"); toolTip.add(EnumChatFormatting.DARK_GREEN + "Dim: " + dim + " X: " + posX + " Y: " + posY + " Z: " + posZ); } } } _________________________________________________________________________________________________________ New [In Progress] Code _________________________________________________________________________________________________________ public void NullCheck(ItemStack stack){ if(stack.getTag() == null){ stack.setTag(new CompoundTag()); } } public CompoundTag GetOrCreateData(ItemStack s){ NullCheck(s); if (s.getTag().contains("LocationData")) { return s.getTag().get("LocationData"); } return new CompoundTag(); } public CompoundTag DataTag(ItemStack s, Vec3 p, String w){ CompoundTag data = GetOrCreateData(s); data.putDouble("x", p.x); data.putDouble("y", p.y); data.putDouble("z", p.z); data.putString("world", w); return data; } /* TEST FUNCTION */ public String Test_GetDimension(Player player){ return player.level.dimension().location().toString() } @Override public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) { ItemStack stack = pPlayer.getItemInHand(pUsedHand); Vec3 Pos = pPlayer.position(); if (pPlayer.isCrouching()){ CompoundTag data = DataTag(stack, Pos, Test_GetDimension(pPlayer)); stack.getTag().put("LocationData", data); stack.setHoverName((new TextComponent("Teleport Device")).withStyle(ChatFormatting.DARK_RED)); } return super.use(pLevel, pPlayer, pUsedHand); } _________________________________________________________________________________________________________ Summary _________________________________________________________________________________________________________ [ Dimension ID ] I know that the Dimension ID is no longer stored in the Entity, so I'm looking for a new way to get what Dimension the player is in. The original idea was to teleport the player to the Dimension as well as the coordinates, but I couldn't get that to work out. So now, it's to prevent the device from teleporting you to the stored coordinates unless you're in that Dimension. In the old code, i would use the Number ID of the Dimension, in the attempted new code, I was trying to use the folder / location path name. { "overworld", "the_nether", "the_end' }. But all it did was return blank for me. [Tooltip / Hover Text] I know I tried using "Item#appendHoverText" and using List<Component>, but it didn't work at all and I can't find the Test_Function for it in my notes. From memory, it was something like: this.appendHoverText(stack, pLevel, new ArrayList<Component>().add(new TextComponent("Test")), TooltipFlag.Default.NORMAL); _________________________________________________________________________________________________________ I hope that all made sense lol. If you happen to know how i could get around this, I would be very grateful.
-
max2461 changed their profile photo
-
1.14.4 GUI without container or tileentity
max2461 replied to Daniel Rollins's topic in Modder Support
The Screen class you're using is trying to run on the server i'm guessing. Calling it from your client proxy should fix it. MyScreenObjects Class: public class MyScreenObjects{ @ObjectHolder("modid:myobjectholder") public static ContainerType<ModContainer> ModContainerScreen; } ClientProxy: (IMCOMPLETE PROXY CLASS) You can find a tutorial somewhere on how to set it up right if you don't already have one. public class ClientProxy implements ProxyInterface{ @Override public void init() { ScreenManager.registerFactory(MyScreenObjects.ModContainerScreen, MyModScreenClass::new); } } *called in your main class -
[1.14.4] [SOLVED] How can i override a vanilla function on a Villager?
max2461 replied to max2461's topic in Modder Support
Hey everyone, i just wanted to update the thread in case anyone else needs more detail on how to do something similar to this. I used Animefan8888's suggestion: and found that EntityInteractSpecific worked better for me. As i have a lot of custom functions all over my mod it wouldn't do any good to post my code but here is a breakdown for some direction! @SubscribeEvent public void EntityInteract(EntityInteractSpecific event) { if(event.getTarget() instanceof [ENTITY YOU WANT]){ //Eg: CowEntity, ChickenEntity. if(event.getItemStack().getItem()==[YOUR ITEM]){ //Eg: Items.NAME_TAG if( [ON THE SERVER] ){ itemstack.interactWithEntity([PLAYER],[ENTITY],[HAND]); /* Cancel the event on the server to prevent other item interactions from passing along with your custom interaction. */ event.setCancellationResult(ActionResultType.SUCCESS); event.setCanceled(true); } if([ON THE CLIENT]){ /* You need to also cancel the event on the client to prevent things like GUI's to apear in villagers, or other process interactions */ event.setCancellationResult(ActionResultType.SUCCESS); event.setCanceled(true); } } } } -
So back in 1.12 the villagers had a bug where you couldn't use a nametag on them because- guess what right clicking does on a villager? BOOM. i am a loser who made the same mistake now... I have a custom item that is supposed to be used on entities, but when i look at the name-tag code, i didn't see how it was fixed, so i went to the villagers code and found this: VillagerEntity#processInteract public boolean processInteract(PlayerEntity player, Hand hand) { ItemStack itemstack = player.getHeldItem(hand); boolean flag = itemstack.getItem() == Items.NAME_TAG; if (flag) { itemstack.interactWithEntity(player, this, hand); return true; } else if (itemstack.getItem() != Items.VILLAGER_SPAWN_EGG && this.isAlive() && !this.func_213716_dX() && !this.isSleeping() && !player.isSneaking()) { if (this.isChild()) { this.shakeHead(); return super.processInteract(player, hand); } else { boolean flag1 = this.getOffers().isEmpty(); if (hand == Hand.MAIN_HAND) { if (flag1 && !this.world.isRemote) { this.shakeHead(); } player.addStat(Stats.TALKED_TO_VILLAGER); } if (flag1) { return super.processInteract(player, hand); } else { if (!this.world.isRemote && !this.offers.isEmpty()) { this.func_213740_f(player); } return true; } } } else { return super.processInteract(player, hand); } } How can i go about adding my custom item into this field? Is there a method i could use to override only this particular function? SOLUTION HERE:
-
[1.14.4][SOLVED] TileEntity isn't replacing the block placed.
max2461 replied to max2461's topic in Modder Support
Thank you very much, you are correct. I needed to override IForgeBlock#hasTileEntity. You are a life saver! -
So i have been fighting with this for a while now and have tried fixing it in a multitude of different ways... I know its registering because under "Block Entities" i see my block. But when i place the block, nothing happens besides the normal block getting placed, and when i try to use: it comes back and says: "ShelfingTile" Class: public class ShelfingTile extends TileEntity implements ITickableTileEntity{ public ShelfingTile(){ super(SHELFING_TILE); } @Override public void tick() { MainCore.LOGGER.debug("TileEntityTick"); } } "Registry Events" Class Code Snippit: private static Item.Properties GetNewItemProperties(){ Item.Properties properties = new Item.Properties(); return properties; } private static BlockItem GetBlockItem(Block block,String reg_name){ BlockItem blockitem = new BlockItem(block,GetNewItemProperties()); blockitem.setRegistryName(reg_name); return blockitem; } @SubscribeEvent public static void RegisterBlock(final RegistryEvent.Register<Block> event) { event.getRegistry().registerAll ( CoreRegistry.SHELFING = new Shelfing(), ); } @SubscribeEvent public static void RegisterItem(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll ( GetBlockItem(CoreRegistry.SHELFING,Shelfing.reg_name), ); } @SubscribeEvent public static void RegisterTileEntity(final RegistryEvent.Register<TileEntityType<?>> event) { event.getRegistry().registerAll ( TileEntityType.Builder.create(ShelfingTile::new,CoreRegistry.SHELFING).build(null).setRegistryName(Shelfing.reg_name) ); } "CoreRegistry" Code Snippits: @ObjectHolder("MaxM") //ModID public class CoreRegistry{ @ObjectHolder("shelfing") //Shelfing Blocks Registry Name public static Block SHELFING; @ObjectHolder("shelfing") public static TileEntityType<ShelfingTile> SHELFING_TILE; } Enitre Block Class: public class Shelfing extends Block{ public static String reg_name = "shelfing"; public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING; protected static final VoxelShape SHAPE = Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D); private static Block.Properties GetNewBlockProperties(){ float hardness = 1.5f; float resistance = 2.0f; Block.Properties properties = Properties.create(Material.WOOD); properties.sound(SoundType.WOOD); properties.hardnessAndResistance(hardness,resistance); return properties; } public Shelfing() { super(GetNewBlockProperties());setRegistryName(reg_name); this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH)); } @Override public boolean hasTileEntity() { return true; } @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return new ShelfingTile(); } public BlockState getStateForPlacement(BlockItemUseContext context) { return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite()); } public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { return SHAPE; } public boolean isSolid(BlockState state) { return false; } public boolean allowsMovement(BlockState state, IBlockReader worldIn, BlockPos pos, PathType type) { return false; } @Override public BlockState rotate(BlockState state, Rotation rot) { return state.with(FACING, rot.rotate(state.get(FACING))); } @Override public BlockState mirror(BlockState state, Mirror mirrorIn) { return state.rotate(mirrorIn.toRotation(state.get(FACING))); } protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) { builder.add(FACING); } public BlockRenderLayer getRenderLayer() { return BlockRenderLayer.CUTOUT; } }
-
[1.14.4] I don't understand how to Override existing classes.
max2461 replied to max2461's topic in Modder Support
YOU ARE A GOD. -cough- I mean, thank you very much. I admit I am a bit ignorant towards "advanced" methods. It worked great! -
[1.14.4] I don't understand how to Override existing classes.
max2461 replied to max2461's topic in Modder Support
That is a very good point, i don't know why i didn't consider that. However, how can i override an "Interface" function in a class? -
I tried to override things like Enchantment Table's getting power raised by Bookshelves to include one of my custom blocks, but it never took. I have tried many different kinds of overriding classes, but it never seems to work. I was wondering if there is something i am missing. THIS IS NOT EXACT CODE... REWRITTEN FROM MEMORY FOR EXAMPLE. public interface MagicEnchantmentOverride extends IForgeBlock{ @Override default float getEnchantPowerBonus(BlockState state, IWorldReader world, BlockPos pos){ if(this.getBlock() == MyBlocks.MAGICBLOCK){ return this.getBlock() == MyBlocks.MAGICBLOCK ? 1: 0; }else{ return this.getBlock() == Blocks.BOOKSHELF ? 1: 0; } }
-
So in my code for 1.8.1, I used to be able to change Creepers AI tasks like so: @SubscribeEvent public void onEntitySpawn(EntityJoinWorldEvent event) { if (event.entity instanceof EntityCreeper){ EntityCreeper entity = (EntityCreeper) event.entity; for (Object entry : entity.targetTasks.taskEntries.toArray()){ EntityAIBase ai = ((EntityAITasks.EntityAITaskEntry) entry).action; if (ai instanceof EntityAINearestAttackableTarget) entity.targetTasks.removeTask(ai); } for (Object entry : entity.tasks.taskEntries.toArray()){ EntityAIBase ai = ((EntityAITasks.EntityAITaskEntry) entry).action; if (ai instanceof EntityAIAttackOnCollide) entity.tasks.removeTask(ai); } entity.tasks.addTask(1, new EntityAITempt(entity, 1.0D, Items.gunpowder, false)); entity.tasks.addTask(2, new EntityAIPanic(entity, 1.4D)); } } But now, in 1.14.4, i cannot for the life of me figure out how to use the "goal" system in the AI. I have tried different events, new registry of the mob, overriding creeperEntites... Here is a failure chunk of code I tried to rework the 1.8 function to (knowing it would fail): (Also, if it doesn't make any sense its because it's literally me changing tiny things to see what happens after weeks of trying) @SubscribeEvent public void onEntitySpawn(EntityJoinWorldEvent event) { if (event.getEntity() instanceof CreeperEntity){ CreeperEntity creeper = (CreeperEntity) event.getEntity(); for (Task task : creeper.goalSelector.getRunningGoals().filter(PrioritizedGoalPrioritizedGoal).getgoal()){ GoalSelector ai = ((GoalSelector) entry).action; if (ai instanceof EntityAINearestAttackableTarget) entity.targetTasks.removeTask(ai); } } } The Mod in its base form is just to make creepers friendly and maybe attack other things. I just can't get the Goal system right.
-
I don't know if this will help or not, but when I had this issue on the most recent version: (after they removed setupdecompworkspace) I had to run a command: gradlew genEclipseRuns To fix my Eclipse, i had to run these commands in this order: gradlew clean gradlew genEclipseRuns gradlew eclipse it was critical to run "genEclipseRuns" before "eclipse."