Jump to content

Jaycen1000

Members
  • Posts

    10
  • Joined

  • Last visited

Recent Profile Visitors

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

Jaycen1000's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hello, for my mod I will like to add a colorful subtitle, how would I do this, can you give me a code snippet?
  2. Hello, in my mod, I want to clean some things up (Like setting variables back and removing potion effects) when clicking "Save and quit to title". Is this an event or something different, is it even possible?
  3. I can’t believe I didn’t do that, I DID THAT (a bit but enough to remember) when making Swing apps, my mind must have blanked, thanks. Yeah, I know since it extends Item, the class is an item. EDIT: After a min, I did @Override to change the distance (It was just how far your character could reach) and here it is. @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { RayTraceResult mop = this.rayTrace(worldIn, playerIn, false); Item i = null; if(mop != null) { EnumFacing blockHitSide = mop.sideHit; Block blkresult = worldIn.getBlockState(new BlockPos(new BlockPos(mop.getBlockPos().getX(), mop.getBlockPos().getY(), mop.getBlockPos().getZ()))).getBlock(); System.out.println(mop.getBlockPos().getX()); System.out.println(mop.getBlockPos().getY()); System.out.println(mop.getBlockPos().getZ()); MinecraftServer s = FMLCommonHandler.instance().getMinecraftServerInstance(); playerIn.setPosition(mop.getBlockPos().getX(), mop.getBlockPos().getY(),mop.getBlockPos().getZ()); //s.getCommandManager().executeCommand( s, "/tp " + playerIn.getName() + " " + (mop.getBlockPos().getX() + " " + mop.getBlockPos().getY() + " " + mop.getBlockPos().getZ())); } return new ActionResult<ItemStack>(EnumActionResult.PASS, playerIn.getHeldItem(handIn)); } @Override protected RayTraceResult rayTrace(World worldIn, EntityPlayer playerIn, boolean useLiquids) { float f = playerIn.rotationPitch; float f1 = playerIn.rotationYaw; double d0 = playerIn.posX; double d1 = playerIn.posY + (double)playerIn.getEyeHeight(); double d2 = playerIn.posZ; Vec3d vec3d = new Vec3d(d0, d1, d2); float f2 = MathHelper.cos(-f1 * 0.017453292F - (float)Math.PI); float f3 = MathHelper.sin(-f1 * 0.017453292F - (float)Math.PI); float f4 = -MathHelper.cos(-f * 0.017453292F); float f5 = MathHelper.sin(-f * 0.017453292F); float f6 = f3 * f4; float f7 = f2 * f4; double d3 = 200; Vec3d vec3d1 = vec3d.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3); return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids, !useLiquids, false); }
  4. I am doing this from a class that extends Item, but it is saying that it is not visible from my ide, also, would I be able to use reflection to get it to work (like, would it be efficient)? Also, what do you mean by I’m coding it in an item class? And I looked it up and protected meant what I thought. And when I run it and right click, the game crashes (because of the visibility error).
  5. RayTraceResult mop = playerIn.getHeldItemMainhand().getItem().rayTrace(worldIn, playerIn, false); Saying rayTrace is not visible, checked source and it's protected.
  6. Hello, I'm making an item in my mod that when you right click, it will teleport you to where you are facing. Now, I know that since I am using RayCast, it will run on client side only, how do I fix this so I can use teleportation. (I don't want to use /tp command since it clutters logs (Maybe a method is to fix this?)). CODE: @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { RayTraceResult mop = Minecraft.getMinecraft().getRenderViewEntity().rayTrace(200, 1.0F); if(mop != null) { EnumFacing blockHitSide = mop.sideHit; Block blkresult = worldIn.getBlockState(new BlockPos(new BlockPos(mop.getBlockPos().getX(), mop.getBlockPos().getY(), mop.getBlockPos().getZ()))).getBlock(); } System.out.println(mop.getBlockPos().getX()); System.out.println(mop.getBlockPos().getY()); System.out.println(mop.getBlockPos().getZ()); MinecraftServer s = FMLCommonHandler.instance().getMinecraftServerInstance(); //s.getCommandManager().executeCommand( s, "/tp " + playerIn.getName() + " " + (mop.getBlockPos().getX() + " " + mop.getBlockPos().getY() + " " + mop.getBlockPos().getZ())); return new ActionResult<ItemStack>(EnumActionResult.PASS, playerIn.getHeldItem(handIn)); }
  7. After a bit of testing, I got this to work. PlayerFlight.java static boolean val = false; public static void toggleFlight(EntityPlayer playerIn, boolean flight, World worldIn) { if (worldIn.isRemote) { flight = !val; val = !val; System.out.println(flight); //Check Activation by player //playerIn.sendChatToPlayer("Activated by: " + var1 + ""); if (worldIn.isRemote) { //Check Activation by player //playerIn.sendChatToPlayer("Activated by: " + var1 + ""); //Make the player fly playerIn.capabilities.allowFlying = flight; playerIn.capabilities.isFlying = flight; playerIn.motionY += 0; playerIn.capabilities.isFlying = flight; playerIn.fallDistance = 0; playerIn.sendPlayerAbilities(); return; } else { return; } //if(!flight) //{ // playerIn.capabilities.isCreativeMode = false; //} } else { return; } } public static void setFlight(EntityPlayer playerIn, boolean flight, World worldIn) { if (worldIn.isRemote) { //Check Activation by player String var1 = playerIn.getName(); //playerIn.sendChatToPlayer("Activated by: " + var1 + ""); //Make the player fly playerIn.capabilities.allowFlying = flight; playerIn.capabilities.isFlying = flight; playerIn.motionY += 0; playerIn.capabilities.isFlying = flight; playerIn.fallDistance = 0; playerIn.sendPlayerAbilities(); return; } else { return; } } public static void setCommandFlight(EntityPlayer playerIn, boolean flight) { String var1 = playerIn.getName(); //Make the player fly playerIn.capabilities.allowFlying = flight; playerIn.capabilities.isFlying = flight; playerIn.motionY += 1.0; playerIn.capabilities.isFlying = flight; playerIn.fallDistance = 0; playerIn.sendPlayerAbilities(); } And FlyCommand.java HashMap<EntityPlayer, Boolean> flying = new HashMap<EntityPlayer, Boolean>(); boolean val = false; @Override public void execute(MinecraftServer server, ICommandSender sender, String[] params) throws CommandException { World w = sender.getEntityWorld(); EntityPlayer p = (EntityPlayer) sender; try { flying.replace(p, !flying.get(p)); } catch(Exception e) { } if(!flying.containsKey(p)) { flying.put(p, true); } val = !val; PlayerFlight.setCommandFlight(p, flying.get(p)); } @Override public String getName() { return "fly"; } @Override public String getUsage(ICommandSender sender) { return "command.fly.usage"; } That should work with multiplayer, also thank you V0idWa1k3r for telling me about World#isRemote.
  8. Ok, using your feedback, I changed my flight class to this public static void setCommandFlight(EntityPlayer playerIn, boolean flight) { String var1 = playerIn.getName(); //Make the player fly playerIn.capabilities.allowFlying = flight; playerIn.capabilities.isFlying = flight; playerIn.capabilities.isFlying = flight; playerIn.fallDistance = 0; playerIn.sendPlayerAbilities(); } And my execute method to this World w = sender.getEntityWorld(); EntityPlayer p = (EntityPlayer) sender; PlayerFlight.setCommandFlight(p, true); What this does is allow you to fly for a tick (I can see my FOV getting bigger), but then after the tick, it goes off.
  9. I made a flying command which is still in beta, I was able to make it work so you could fly whilst holding an item, CODE: @Override public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag) { if (entity instanceof EntityPlayer) { EntityPlayer Player = (EntityPlayer) entity; if(Player.getHeldItemMainhand() != null && Player.getHeldItemMainhand().getItem() instanceof IHasModel) { PlayerFlight.setFlight(Player, true, world); //System.out.println("holding"); } else { PlayerFlight.setFlight(Player, false, world); } } } This works, but this doesn't, I'm suspecting that you can't cast ICommandSender to EntityPlayer, because this code will not work, the player will do nothing. boolean val = false; @Override public void execute(MinecraftServer server, ICommandSender sender, String[] params) throws CommandException { World w = sender.getEntityWorld(); EntityPlayer p = (EntityPlayer) sender; val = !val; if(w.isRemote) { PlayerFlight.setFlight(p, true, sender.getEntityWorld()); } } @Override public String getName() { return "fly"; } @Override public String getUsage(ICommandSender sender) { return "command.fly.usage"; } And my Flying class. #Note that I know how to use hashmaps and when I get this working ill add multiplayer support. static boolean val = false; public static void toggleFlight(EntityPlayer playerIn, boolean flight, World worldIn) { if (worldIn.isRemote) { flight = !val; val = !val; System.out.println(flight); //Check Activation by player String var1 = playerIn.getName(); //playerIn.sendChatToPlayer("Activated by: " + var1 + ""); //Make the player fly playerIn.capabilities.allowFlying = flight; playerIn.capabilities.isFlying = flight; playerIn.capabilities.isFlying = flight; playerIn.fallDistance = 0; if(flight) { playerIn.motionY += 1.0; } else { playerIn.motionY += -1.0; } //if(!flight) //{ // playerIn.capabilities.isCreativeMode = false; //} playerIn.sendPlayerAbilities(); } else { return; } } public static void setFlight(EntityPlayer playerIn, boolean flight, World worldIn) { if (worldIn.isRemote) { //Check Activation by player String var1 = playerIn.getName(); //playerIn.sendChatToPlayer("Activated by: " + var1 + ""); //Make the player fly playerIn.capabilities.allowFlying = flight; playerIn.capabilities.isFlying = flight; playerIn.capabilities.isFlying = flight; playerIn.fallDistance = 0; //if(!flight) //{ // playerIn.capabilities.isCreativeMode = false; //} playerIn.sendPlayerAbilities(); } else { return; } }
  10. Thank you Opengbil, I was looking on the internet for days with no avail
  11. I want to make my swords look like this in first person And they look like this Here is my sword base: import java.util.Collection; import java.util.Optional; import java.util.UUID; import org.lwjgl.opengl.GL11; import com.google.common.collect.Multimap; import me.Jaycen.FirstMod.Main; import me.Jaycen.FirstMod.init.ModItems; import me.Jaycen.FirstMod.util.IHasModel; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.entity.Render; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.ai.attributes.IAttribute; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; public class SwordBase extends ItemSword implements IHasModel { double speed = 1; private void replaceModifier(Multimap<String, AttributeModifier> modifierMultimap, IAttribute attribute, UUID id, double multiplier) { // Get the modifiers for the specified attribute final Collection<AttributeModifier> modifiers = modifierMultimap.get(attribute.getName()); // Find the modifier with the specified ID, if any final Optional<AttributeModifier> modifierOptional = modifiers.stream().filter(attributeModifier -> attributeModifier.getID().equals(id)).findFirst(); if (modifierOptional.isPresent()) { // If it exists, final AttributeModifier modifier = modifierOptional.get(); modifiers.remove(modifier); // Remove it modifiers.add(new AttributeModifier(modifier.getID(), modifier.getName(), modifier.getAmount() * multiplier, modifier.getOperation())); // Add the new modifier } } @Override public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { final Multimap<String, AttributeModifier> modifiers = super.getAttributeModifiers(slot, stack); if (slot == EntityEquipmentSlot.MAINHAND) { replaceModifier(modifiers, SharedMonsterAttributes.ATTACK_DAMAGE, ATTACK_DAMAGE_MODIFIER, speed); replaceModifier(modifiers, SharedMonsterAttributes.ATTACK_SPEED, ATTACK_SPEED_MODIFIER, speed); } return modifiers; } public SwordBase(String name, ToolMaterial mat, double speed) { super(mat); this.speed = speed; isFull3D(); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(CreativeTabs.COMBAT); ModItems.ITEMS.add(this); } @Override public void registerModels() { Main.proxy.registerItemRenderer(this, 0, "inventory"); } } And my class that registers models package me.Jaycen.FirstMod.util.handlers; import org.lwjgl.opengl.GL11; import me.Jaycen.FirstMod.init.ModBlocks; import me.Jaycen.FirstMod.init.ModItems; import me.Jaycen.FirstMod.items.SwordBase; import me.Jaycen.FirstMod.util.IHasModel; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @EventBusSubscriber public class RegisteryHandler { @SubscribeEvent public static void onItemRegister(RegistryEvent.Register<Item> event) { event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0])); } @SubscribeEvent public static void onBlockRegister(RegistryEvent.Register<Block> event) { event.getRegistry().registerAll(ModBlocks.BLOCKS.toArray(new Block[0])); } @SubscribeEvent public static void onModelRegister(ModelRegistryEvent event) { for(Item item : ModItems.ITEMS) { if(item instanceof IHasModel) { ((IHasModel)item).registerModels(); } } for(Block item : ModBlocks.BLOCKS) { if(item instanceof IHasModel) { ((IHasModel)item).registerModels(); } } } }
×
×
  • Create New...

Important Information

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