
MineModder2000
Members-
Posts
298 -
Joined
-
Last visited
Everything posted by MineModder2000
-
[1.14.4] Modifying Vanilla Content
MineModder2000 replied to MineModder2000's topic in Modder Support
I am using 28.0.27. I can't run from Eclipse, I get errors. Updating may solve the problem. I did, it just goes over how it fires and what not. /** * This event is fired on both sides whenever the player right clicks while targeting a block. * This event controls which of {@link net.minecraft.block.Block#onBlockActivated} and/or {@link net.minecraft.item.Item#onItemUse} * will be called after {@link net.minecraft.item.Item#onItemUseFirst} is called. * Canceling the event will cause none of the above three to be called * * Let result be a return value of the above three methods, or {@link #cancellationResult} if the event is cancelled. * If we are on the client and result is not {@link EnumActionResult#SUCCESS}, the client will then try {@link RightClickItem}. * * There are various results to this event, see the getters below. * Note that handling things differently on the client vs server may cause desynchronizations! */ Canceling the event will cause none of the above three to be called, so it should work. -
[1.14.4] Making a Trident like item
MineModder2000 replied to MineModder2000's topic in Modder Support
I don't love him, but I got it working now. -
[1.14.4] Modifying Vanilla Content
MineModder2000 replied to MineModder2000's topic in Modder Support
Hmm, i tried both of the following, no cigar : @SubscribeEvent public void rightClickBlock(RightClickBlock event) { event.setCanceled(true); } @SubscribeEvent public void entityInteract(EntityInteract event) { event.setCanceled(true); } PlayerInteractEvent is where these are located. -
[1.14.4] Modifying Vanilla Content
MineModder2000 replied to MineModder2000's topic in Modder Support
Ah, I did this before asking but I missed it. It has the literal name : RightClickBlock, doh! -
[1.14.4] Making a Trident like item
MineModder2000 replied to MineModder2000's topic in Modder Support
package mymod.thrown; import java.util.Map; import com.google.common.collect.ImmutableMap.Builder; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.nbt.CompoundNBT; import net.minecraft.stats.Stats; import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class Chert extends Item { // Copies EggItem protected static final Map<Block, Block> BLOCK_STRIPPING_MAP = new Builder<Block, Block>().put(Blocks.OAK_LOG, Blocks.CAMPFIRE).build(); CompoundNBT h; public Chert(Item.Properties builder) { super(builder); h = new CompoundNBT(); h.putInt("tick_last", 0); } /** * Called to trigger the item's "innate" right click behavior. To handle when this item is used on a Block, see * {@link #onItemUse}. */ public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); if (playerIn.ticksExisted - h.getInt("tick_last") >= 16) { h.putInt("tick_last", playerIn.ticksExisted); if (!playerIn.abilities.isCreativeMode) { itemstack.shrink(1); } worldIn.playSound((PlayerEntity) null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F)); if (!worldIn.isRemote) { Chert_Entity chert_entity = new Chert_Entity(worldIn, playerIn); chert_entity.func_213884_b(itemstack); chert_entity.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.15F, 3.0F); worldIn.addEntity(chert_entity); } playerIn.addStat(Stats.ITEM_USED.get(this)); return new ActionResult<>(ActionResultType.SUCCESS, itemstack); } else return new ActionResult<>(ActionResultType.PASS, itemstack); } public ActionResultType onItemUse(ItemUseContext context) { World world = context.getWorld(); BlockPos blockpos = context.getPos(); BlockState blockstate = world.getBlockState(blockpos); Block block = BLOCK_STRIPPING_MAP.get(blockstate.getBlock()); if (block != null && !world.isRemote) { world.setBlockState(blockpos, block.getDefaultState(), 11); } return ActionResultType.SUCCESS; } } Is this all correct NBT-wise? Sometimes it won't chuck (I am testing it with my old code since I can't get custom entity to render), it has to due with the fact that this code is Item Stack specific. If I switch to another item, or another stack of chert, there is good chance they won't chuck anymore. I am not sure how to work the logic so that this doesn't happen. -
[1.14.4] Modifying Vanilla Content
MineModder2000 replied to MineModder2000's topic in Modder Support
Thanks.....HOW. -
[1.14.4] Modifying Vanilla Content
MineModder2000 replied to MineModder2000's topic in Modder Support
Bump. -
[1.14.4] Modifying Vanilla Content
MineModder2000 replied to MineModder2000's topic in Modder Support
Is it possible to disable right click on interaction blocks such as furnace, smoker, etc.? -
[1.14.4] Modifying Vanilla Content
MineModder2000 replied to MineModder2000's topic in Modder Support
I'm stoked that I got this to work, my test of farmers offering diamond axes was successful. I just realized that whatever trades the villagers load with, that's it, you can't change it retroactively, important note for testing. -
[1.14.4] Modifying Vanilla Content
MineModder2000 replied to MineModder2000's topic in Modder Support
My dreams of becoming a ballerina? I see the public field that I can change in VillagerTrades, I'll take a crack at it. -
[1.14.4] Making a Trident like item
MineModder2000 replied to MineModder2000's topic in Modder Support
You also didn't say what method you meant.... I don't understand where I am suppose to do this. -
[1.14.4] Making a Trident like item
MineModder2000 replied to MineModder2000's topic in Modder Support
You mean this : public void processPacket(IClientPlayNetHandler handler) { handler.handleSpawnObject(); } I don't understand, populate it with what data. That method only accepts SSpawnObjectPackets.... -
[1.14.4] Making a Trident like item
MineModder2000 replied to MineModder2000's topic in Modder Support
package mymod.spear; import java.io.IOException; import java.util.UUID; import net.minecraft.client.network.play.IClientPlayNetHandler; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.network.IPacket; import net.minecraft.network.PacketBuffer; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.util.registry.Registry; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public class SSpawnSpearPacket implements IPacket<IClientPlayNetHandler> { private int entityId; private UUID uniqueId; private double x; private double y; private double z; private int speedX; private int speedY; private int speedZ; private int pitch; private int yaw; private EntityType<?> type; private int data; public SSpawnSpearPacket() { } public SSpawnSpearPacket(int p_i50777_1_, UUID p_i50777_2_, double p_i50777_3_, double p_i50777_5_, double p_i50777_7_, float p_i50777_9_, float p_i50777_10_, EntityType<?> p_i50777_11_, int p_i50777_12_, Vec3d p_i50777_13_) { this.entityId = p_i50777_1_; this.uniqueId = p_i50777_2_; this.x = p_i50777_3_; this.y = p_i50777_5_; this.z = p_i50777_7_; this.pitch = MathHelper.floor(p_i50777_9_ * 256.0F / 360.0F); this.yaw = MathHelper.floor(p_i50777_10_ * 256.0F / 360.0F); this.type = p_i50777_11_; this.data = p_i50777_12_; this.speedX = (int)(MathHelper.clamp(p_i50777_13_.x, -3.9D, 3.9D) * 8000.0D); this.speedY = (int)(MathHelper.clamp(p_i50777_13_.y, -3.9D, 3.9D) * 8000.0D); this.speedZ = (int)(MathHelper.clamp(p_i50777_13_.z, -3.9D, 3.9D) * 8000.0D); } public SSpawnSpearPacket(Spear_Entity p_i50778_1_) { this(p_i50778_1_, 0); } public SSpawnSpearPacket(Spear_Entity entityIn, int typeIn) { this(entityIn.getEntityId(), entityIn.getUniqueID(), entityIn.posX, entityIn.posY, entityIn.posZ, entityIn.rotationPitch, entityIn.rotationYaw, entityIn.getType(), typeIn, entityIn.getMotion()); } public SSpawnSpearPacket(Spear_Entity p_i50779_1_, EntityType<Spear_Entity> p_i50779_2_, int p_i50779_3_, BlockPos p_i50779_4_) { this(p_i50779_1_.getEntityId(), p_i50779_1_.getUniqueID(), (double)p_i50779_4_.getX(), (double)p_i50779_4_.getY(), (double)p_i50779_4_.getZ(), p_i50779_1_.rotationPitch, p_i50779_1_.rotationYaw, p_i50779_2_, p_i50779_3_, p_i50779_1_.getMotion()); } /** * Reads the raw packet data from the data stream. */ public void readPacketData(PacketBuffer buf) throws IOException { this.entityId = buf.readVarInt(); this.uniqueId = buf.readUniqueId(); this.type = Registry.ENTITY_TYPE.getByValue(buf.readVarInt()); this.x = buf.readDouble(); this.y = buf.readDouble(); this.z = buf.readDouble(); this.pitch = buf.readByte(); this.yaw = buf.readByte(); this.data = buf.readInt(); this.speedX = buf.readShort(); this.speedY = buf.readShort(); this.speedZ = buf.readShort(); } /** * Writes the raw packet data to the data stream. */ public void writePacketData(PacketBuffer buf) throws IOException { buf.writeVarInt(this.entityId); buf.writeUniqueId(this.uniqueId); buf.writeVarInt(Registry.ENTITY_TYPE.getId(this.type)); buf.writeDouble(this.x); buf.writeDouble(this.y); buf.writeDouble(this.z); buf.writeByte(this.pitch); buf.writeByte(this.yaw); buf.writeInt(this.data); buf.writeShort(this.speedX); buf.writeShort(this.speedY); buf.writeShort(this.speedZ); } public void processPacket(IClientPlayNetHandler handler) { //handler.handleSpawnObject(this); } @OnlyIn(Dist.CLIENT) public int getEntityID() { return this.entityId; } @OnlyIn(Dist.CLIENT) public UUID getUniqueId() { return this.uniqueId; } @OnlyIn(Dist.CLIENT) public double getX() { return this.x; } @OnlyIn(Dist.CLIENT) public double getY() { return this.y; } @OnlyIn(Dist.CLIENT) public double getZ() { return this.z; } @OnlyIn(Dist.CLIENT) public double func_218693_g() { return (double)this.speedX / 8000.0D; } @OnlyIn(Dist.CLIENT) public double func_218695_h() { return (double)this.speedY / 8000.0D; } @OnlyIn(Dist.CLIENT) public double func_218692_i() { return (double)this.speedZ / 8000.0D; } @OnlyIn(Dist.CLIENT) public int getPitch() { return this.pitch; } @OnlyIn(Dist.CLIENT) public int getYaw() { return this.yaw; } @OnlyIn(Dist.CLIENT) public EntityType<?> getType() { return this.type; } @OnlyIn(Dist.CLIENT) public int getData() { return this.data; } } Well Houston we have progress, it doesn't chuck tridents anymore. Well like my other throwable, it doesn't chuck anything, but hey it's something. I tried both of the following for ResourceLocation in Spear_Renderer like so : public static final ResourceLocation field_203087_a = new ResourceLocation("mymod", "textures/entity/spear.png"); public static final ResourceLocation field_203087_a = new ResourceLocation("mymod/textures/entity/spear.png"); No cigar.... -
[1.14.4] Making a Trident like item
MineModder2000 replied to MineModder2000's topic in Modder Support
I don't see how that would make any difference, what code what I change in it making my own? -
[1.14.4] Making a Trident like item
MineModder2000 replied to MineModder2000's topic in Modder Support
Okay changed the EntityType field. I found the method, but I'm not seeing anything in SSpawnObjectPacket that stands out... package mymod.spear; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType.IFactory; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.TridentEntity; import net.minecraft.item.ItemStack; import net.minecraft.network.IPacket; import net.minecraft.network.play.server.SSpawnObjectPacket; import net.minecraft.world.World; public class Spear_Entity extends TridentEntity implements IFactory<Spear_Entity>{ SSpawnObjectPacket gl; public Spear_Entity(EntityType<Spear_Entity> p_i50148_1_, World p_i50148_2_) { super(p_i50148_1_, p_i50148_2_); } public Spear_Entity(World worldIn, PlayerEntity playerentity, ItemStack stack) { super(worldIn, playerentity, stack); } @Override public Spear_Entity create(EntityType<Spear_Entity> p_create_1_, World p_create_2_) { return null; } @Override public IPacket<?> createSpawnPacket() { Entity entity = this.getShooter(); return new SSpawnObjectPacket(this, entity == null ? 0 : entity.getEntityId()); } } -
[1.14.4] Modifying Vanilla Content
MineModder2000 replied to MineModder2000's topic in Modder Support
Please show me where that is. -
(SOLVED) [1.14.4] Block construction and State changing
MineModder2000 replied to MineModder2000's topic in Modder Support
You'll have to explain the first one more. The whole point of the if statement and tick variables in the onItemRightClick method is to prevent the item from being thrown too rapidly. How else should I do this? Removing with the with() method did the trick, now any blocks can be converted back and forth, thanks. -
[1.14.4] Modifying Vanilla Content
MineModder2000 replied to MineModder2000's topic in Modder Support
Anyway to change what villagers have to trade, and their prices? -
(SOLVED) [1.14.4] Block construction and State changing
MineModder2000 replied to MineModder2000's topic in Modder Support
I see. I've been testing out block conversion on right click with one of my own custom items by copying code from AxeItem. I can get wood / plank / log / stripped blocks to convert from one to another, but it only works for those types, nothing else. I noticed also that minecraft.block package doesn't have any log / wood / plank / stripped blocks in it, so where are they defined? This is what I tried : package mymod.thrown; import java.util.Map; import com.google.common.collect.ImmutableMap.Builder; import mymod.My_Mod; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.RotatedPillarBlock; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.stats.Stats; import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class Chert extends Item { // Copies EggItem protected static final Map<Block, Block> BLOCK_STRIPPING_MAP = new Builder<Block, Block>().put(Blocks.CACTUS, Blocks.JUNGLE_LOG).build(); public Chert(Item.Properties builder) { super(builder); } /** * Called to trigger the item's "innate" right click behavior. To handle when this item is used on a Block, see * {@link #onItemUse}. */ public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); if (playerIn.ticksExisted - My_Mod.tick_last >= 16) { My_Mod.tick_last = playerIn.ticksExisted; if (!playerIn.abilities.isCreativeMode) { itemstack.shrink(1); } worldIn.playSound((PlayerEntity) null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F)); if (!worldIn.isRemote) { Chert_Entity chert_entity = new Chert_Entity(worldIn, playerIn); chert_entity.func_213884_b(itemstack); chert_entity.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.15F, 3.0F); worldIn.addEntity(chert_entity); } playerIn.addStat(Stats.ITEM_USED.get(this)); return new ActionResult<>(ActionResultType.SUCCESS, itemstack); } else return new ActionResult<>(ActionResultType.PASS, itemstack); } public ActionResultType onItemUse(ItemUseContext context) { World world = context.getWorld(); BlockPos blockpos = context.getPos(); BlockState blockstate = world.getBlockState(blockpos); Block block = BLOCK_STRIPPING_MAP.get(blockstate.getBlock()); if (block != null && !world.isRemote) { world.setBlockState(blockpos, block.getDefaultState().with(RotatedPillarBlock.AXIS, blockstate.get(RotatedPillarBlock.AXIS)), 11); } return ActionResultType.SUCCESS; } } -
[1.14.4] Making a Trident like item
MineModder2000 replied to MineModder2000's topic in Modder Support
Oh right, but it since it's still rendering the trident, it's not even using my SpearRenderer class. I changed the path to this : "mymod/textures/entity/spear.png", after creating that package, I already had the texture file ready. The classes I made aren't being used at all.... -
[1.14.4] Making a Trident like item
MineModder2000 replied to MineModder2000's topic in Modder Support
Okay did it.... private void setup(final FMLCommonSetupEvent event) { // some preinit code LOGGER.info("HELLO FROM PREINIT"); RenderingRegistry.registerEntityRenderingHandler(Spear_Entity.class, Spear_Factory.INSTANCE); RenderingRegistry.registerEntityRenderingHandler(Chert_Entity.class, manager -> new SpriteRenderer<Chert_Entity>(manager, Minecraft.getInstance().getItemRenderer())); } Still no visible projectiles, it just makes the noise.... -
[1.14.4] Making a Trident like item
MineModder2000 replied to MineModder2000's topic in Modder Support
The trident had 3 jsons, so I coped them and changed appropriate names / paths : spear_in_hand spear_throwing spear As for what that function does, it's better to ask Mojand, I just copied their Trident_Renderer class. It looks though, that it performs necessary transformations to make the spear do its spear thing when its held back and then tossed. -
[1.14.4] Making a Trident like item
MineModder2000 replied to MineModder2000's topic in Modder Support
And then make a factory and register the Entity class with it? -
[1.14.4] Making a Trident like item
MineModder2000 replied to MineModder2000's topic in Modder Support
Oh right, I had in the correct place before but things got moved around. I put that line back inside the "setup" method. I'm just going to show you all of my classes : Spear Entity Spear Factory Spear Model Spear Renderer Spear_TEISR Spear @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { LOGGER.info("HELLO from Register Items"); event.getRegistry().registerAll( ItemList.spear = new Spear(new Item.Properties().maxDamage(10).setTEISR(teisr).group(ItemGroup.COMBAT)).setRegistryName(location("spear")), ); } @SubscribeEvent public static void registerEntities(final RegistryEvent.Register<EntityType<?>> event) { LOGGER.debug("Hello from Register Entities"); event.getRegistry().registerAll( EntityType.Builder.<Spear_Entity>create(Spear_Entity::new, EntityClassification.MISC).build("spear").setRegistryName("mymod", "spear"), ); } private static ResourceLocation location(String name) { return new ResourceLocation("mymod", name); } -
[1.14.4] Making a Trident like item
MineModder2000 replied to MineModder2000's topic in Modder Support
@SubscribeEvent public static void registerEntities(final RegistryEvent.Register<EntityType<?>> event) { LOGGER.debug("Hello from Register Entities"); event.getRegistry().registerAll( EntityType.Builder.<Spear_Entity>create(Spear_Entity::new, EntityClassification.MISC).build("spear").setRegistryName("mymod", "spear"), ); RenderingRegistry.registerEntityRenderingHandler(Spear_Entity.class, Spear_Factory.INSTANCE); } Did this, still chucking tridents instead of spears...