Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

MrMarnic

Members
  • Posts

    39
  • Joined

  • Last visited

Everything posted by MrMarnic

  1. In 1.12.2 the type of the RayTraceResult of the ProjectileImpactEvent was Block if the arrow hit a block. But int 1.14.3 it is only Block if the arrow hits a block the player is directly looking at. Everytime else it is miss. This is my code: @SubscribeEvent public static void projectileHit(ProjectileImpactEvent.Arrow e) { System.out.println(e.getRayTraceResult().getType()); } Again it is only Block if the hit block is highlighted. I 1.12.2 it worked.
  2. In 1.12.2 you can add enchantments to an ItemStack like this. ItemStack stack = new ItemStack(Items.DIAMOND_SWORD); stack.addEnchantment(Enchantments.SHARPNESS,4);
  3. The strange thing is it is working if the velocity is 4 or minor. Then the bug is occuring.
  4. Here is my problem. I have create a custom bow which is working fine but when I am increasing the velocity of the arrows, the arrows have an offset when flying. They are not flying as straight as the arrows from the vanilla bow. Here is my code: public class BasicBow extends ItemBow{ public BasicBow(String name) { setRegistryName(name); setUnlocalizedName(name); setMaxDamage(384); this.addPropertyOverride(new ResourceLocation("pull"), new IItemPropertyGetter() { @SideOnly(Side.CLIENT) public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) { if (entityIn == null) { return 0.0F; } else { return !(entityIn.getActiveItemStack().getItem() instanceof ItemBow) ? 0.0F : (float)(stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20f; } } }); } @Override public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) { if (entityLiving instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)entityLiving; boolean flag = entityplayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0; ItemStack itemstack = this.findAmmo(entityplayer); int i = this.getMaxItemUseDuration(stack) - timeLeft; i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(stack, worldIn, entityplayer, i, !itemstack.isEmpty() || flag); if (i < 0) return; if (!itemstack.isEmpty() || flag) { if (itemstack.isEmpty()) { itemstack = new ItemStack(Items.ARROW); } float f = getArrowVelocity(i); if ((double)f >= 0.1D) { boolean flag1 = entityplayer.capabilities.isCreativeMode || (itemstack.getItem() instanceof ItemArrow && ((ItemArrow) itemstack.getItem()).isInfinite(itemstack, stack, entityplayer)); if (!worldIn.isRemote) { ItemArrow itemarrow = (ItemArrow)(itemstack.getItem() instanceof ItemArrow ? itemstack.getItem() : Items.ARROW); EntityArrow entityarrow = itemarrow.createArrow(worldIn, itemstack, entityplayer); entityarrow = this.customizeArrow(entityarrow); entityarrow.shoot(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0F, f * 4, 1f); if (f == 1.0F) { entityarrow.setIsCritical(true); } int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack); if (j > 0) { entityarrow.setDamage(entityarrow.getDamage() + (double)j * 0.5D + 0.5D + settings.getDamage()); } int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack); if (k > 0) { entityarrow.setKnockbackStrength(k); } if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) { entityarrow.setFire(100); } stack.damageItem(1, entityplayer); if (flag1 || entityplayer.capabilities.isCreativeMode && (itemstack.getItem() == Items.SPECTRAL_ARROW || itemstack.getItem() == Items.TIPPED_ARROW)) { entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY; } worldIn.spawnEntity(entityarrow); } worldIn.playSound((EntityPlayer)null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); if (!flag1 && !entityplayer.capabilities.isCreativeMode) { itemstack.shrink(1); if (itemstack.isEmpty()) { entityplayer.inventory.deleteStack(itemstack); } } entityplayer.addStat(StatList.getObjectUseStats(this)); } } } } } In this line I am applying the velocity: entityarrow.shoot(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0F, f * 4.5f, 1f); When I multiply f with an float higher than 4 the bug is occuring. It would be nice if you can help me.
  5. I know that. But I wanted to replace an existing recipe like in this post: http://www.minecraftforge.net/forum/topic/59711-112-override-vanilla-recipe/
  6. In 1.12.2 this has worked to get the event for IRecipe @SubscribeEvent public void recipe(RegistryEvent.Register<IRecipe> e) { } But this doesn`t work dany more. So my question is how is the new way?
  7. I overlooked my code and I do not need it any more. But shouldn`t it work. Btw I used that event because I tought in that event everything should be registered.
  8. I am only trying to get a list of all entities in the game.
  9. MinecraftVersion: 1.13.2 ForgeVersion: 25.0.26 I am currently updating my mod and I need to get all registered entities in the game. So i used this code in the FMLLoadCompleteEvent: public void complete(final FMLLoadCompleteEvent e) { System.out.println("ITEMS: " + ForgeRegistries.ITEMS.getValues().size()); System.out.println("ENTITIES: " + ForgeRegistries.ENTITIES.getValues().size()); } But the ouput is: ITEMS: 797 ENTITIES: 0 So the erros is that the ForgeRegistry for Entities is empty. Btw. in 1.12.2 it has worked.
  10. I know that the ItemStacks and that's the problem. I don't know where the ItemStack is null where it must be empty
  11. I made a custom gui that looks like the one from the furnace . The inventory should not be saved and shoul be opened by and item. It should only be an inventory where you can move items. When I'm doing things in the player's inventory part everything goes well. But when i put an item in the inventory of the dispenser and try to left click to it the game crashes with an java.lang.NullPointerException: Rendering screen . But when i left click+shift everything works. I have no more ideas what to do . I hope you can help me . Error Log: GUI class: package me.marnic.mod.gui; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.event.terraingen.BiomeEvent.GetWaterColor; public class TestGui extends GuiContainer{ public TestGui(Container inventorySlotsIn) { super(inventorySlotsIn); // TODO Auto-generated constructor stub } final ResourceLocation loc = new ResourceLocation("m_mod","textures/gui/test_gui.png"); @Override public boolean doesGuiPauseGame() { return false; } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { mc.getTextureManager().bindTexture(loc); drawTexturedModalRect(width / 2 - 176 / 2, height / 2 - 166 / 2, 0, 0, 176, 166); super.drawScreen(mouseX, mouseY, partialTicks); } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { // TODO Auto-generated method stub } } GUI Container: package me.marnic.mod.gui; import me.marnic.mod.item.BasicItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ClickType; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.items.SlotItemHandler; public class TestGuiContainer extends Container { public TestGuiInventory inv; public TestGuiContainer(IInventory playerInventory, TestGuiInventory dispenserInventoryIn) { this.inv = dispenserInventoryIn; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { this.addSlotToContainer(new Slot(dispenserInventoryIn, j + i * 3, 62 + j * 18, 17 + i * 18)); } } for (int k = 0; k < 3; ++k) { for (int i1 = 0; i1 < 9; ++i1) { this.addSlotToContainer(new Slot(playerInventory, i1 + k * 9 + 9, 8 + i1 * 18, 84 + k * 18)); } } for (int l = 0; l < 9; ++l) { this.addSlotToContainer(new Slot(playerInventory, l, 8 + l * 18, 142)); } } /** * Determines whether supplied player can use this container */ @Override public boolean canInteractWith(EntityPlayer playerIn) { return true; } /** * Handle when the stack in slot {@code index} is shift-clicked. Normally this moves the stack between the player * inventory and the other inventory(s). */ @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (index < 9) { if (!this.mergeItemStack(itemstack1, 9, 45, true)) { return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 0, 9, false)) { return ItemStack.EMPTY; } if (itemstack1.isEmpty()) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } if (itemstack1.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } slot.onTake(playerIn, itemstack1); } return itemstack; } } GUI Inventory: package me.marnic.mod.gui; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.items.IItemHandler; public class TestGuiInventory implements IInventory{ public int SIZE = 9; public NonNullList<ItemStack> items = NonNullList.withSize(SIZE, ItemStack.EMPTY); InventoryPlayer p; @Override public String getName() { // TODO Auto-generated method stub return "GuiInv"; } @Override public boolean hasCustomName() { // TODO Auto-generated method stub return false; } @Override public ITextComponent getDisplayName() { // TODO Auto-generated method stub return null; } @Override public int getSizeInventory() { // TODO Auto-generated method stub return items.size(); } @Override public boolean isEmpty() { for(ItemStack s:items) { if(!s.isEmpty()) { return false; } } return true; } @Override public ItemStack getStackInSlot(int index) { // TODO Auto-generated method stub return items.get(index); } @Override public ItemStack decrStackSize(int index, int count) { // TODO Auto-generated method stub return null; } @Override public ItemStack removeStackFromSlot(int index) { // TODO Auto-generated method stub return items.set(index, ItemStack.EMPTY); } @Override public void setInventorySlotContents(int index, ItemStack stack) { items.set(index, stack); } @Override public int getInventoryStackLimit() { // TODO Auto-generated method stub return 64; } @Override public void markDirty() { // TODO Auto-generated method stub } @Override public boolean isUsableByPlayer(EntityPlayer player) { // TODO Auto-generated method stub return player.getDistanceSq(player) <= 64.0D; } @Override public void openInventory(EntityPlayer player) { // TODO Auto-generated method stub } @Override public void closeInventory(EntityPlayer player) { // TODO Auto-generated method stub } @Override public boolean isItemValidForSlot(int index, ItemStack stack) { // TODO Auto-generated method stub return true; } @Override public int getField(int id) { // TODO Auto-generated method stub return 0; } @Override public void setField(int id, int value) { // TODO Auto-generated method stub } @Override public int getFieldCount() { // TODO Auto-generated method stub return 0; } @Override public void clear() { for(ItemStack s:items) { s = ItemStack.EMPTY; } } } GUI Handler: package me.marnic.mod.gui; import me.marnic.mod.main.Main; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; public class GUIHandler implements IGuiHandler{ public static int TEST_GUI = 0; @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID==TEST_GUI) { return new TestGuiContainer(player.inventory,new TestGuiInventory()); } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID==TEST_GUI) { return new TestGui(new TestGuiContainer(player.inventory,new TestGuiInventory())); } return null; } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.