Jump to content

[1.12.2] arrows fired spawned don't do damage


Merthew

Recommended Posts

The arrows that i fire from my tileentiy don't actually do damage. Is there a way to fix this?

 

Code File:

Spoiler

package merthew.mod.block.divinity.altar;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.Nullable;

import merthew.mod.inventory.EobItemHandler;
import merthew.mod.util.handlers.packets.DivineAltarButtonMessage;
import merthew.mod.util.handlers.packets.PacketHandler;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.IBehaviorDispenseItem;
import net.minecraft.entity.projectile.EntityTippedArrow;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.registry.RegistryDefaulted;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.CapabilityItemHandler;

public class TileEntityAltar extends TileEntity implements ITickable{
	public static final RegistryDefaulted<Item, IBehaviorDispenseItem> DISPENSE_BEHAVIOR_REGISTRY = new RegistryDefaulted<Item, IBehaviorDispenseItem>(new BehaviorDefaultDispenseItem());
	
	private final EobItemHandler itemHandler;
	boolean isCheckStart;
	boolean isPressed;
	int ticksPressed;
	
    boolean rainOfDeath;
    int rainOfDeathTick;
	
	public enum Ritual {
		RAIN, CLEAR, RAIN_OF_DEATH
	}
	
	Map<ArrayList<Item>, Ritual> recipes = new HashMap<ArrayList<Item>, Ritual>();
	
	public TileEntityAltar() {
		super();
		itemHandler = new EobItemHandler(8);
		
		ArrayList<Item> rain = new ArrayList<Item>();
		for(int i = 0; i < 8; i ++) {
			rain.add(Items.WATER_BUCKET);
		}
		recipes.put(rain, Ritual.RAIN);
		
		ArrayList<Item> clear = new ArrayList<Item>();
		for(int i = 0; i < 8; i ++) {
			clear.add(Item.getItemFromBlock(Blocks.AIR));
		}
		recipes.put(clear, Ritual.RAIN_OF_DEATH);
	}

	@Override
	public void update() {
		if(isPressed) {
			ticksPressed ++;
		}
		
		if(ticksPressed >= 10) {
			isPressed = false;
			ticksPressed = 0;
		}
		
		if(isCheckStart) {
			System.out.println("Check Start is a go.");
			if(shouldStart()) {
				System.out.println("Should Start is a go.");
				ArrayList<Item> inputs = new ArrayList<Item>();
				inputs.add(itemHandler.getStackInSlot(0).getItem());
				inputs.add(itemHandler.getStackInSlot(1).getItem());
				inputs.add(itemHandler.getStackInSlot(2).getItem());
				inputs.add(itemHandler.getStackInSlot(3).getItem());
				inputs.add(itemHandler.getStackInSlot(4).getItem());
				inputs.add(itemHandler.getStackInSlot(5).getItem());
				inputs.add(itemHandler.getStackInSlot(6).getItem());
				inputs.add(itemHandler.getStackInSlot(7).getItem());
				Ritual r = recipes.get(inputs);
				System.out.println("Ritual: " + r);
				
				switch(r) {
				case RAIN:
					PacketHandler.INSTANCE.sendToServer(new DivineAltarButtonMessage(0));
		            break;
				case CLEAR:
					PacketHandler.INSTANCE.sendToServer(new DivineAltarButtonMessage(1));
					break;
				case RAIN_OF_DEATH:
					rainOfDeath = true;
					System.out.println("Starting rain of death.");
				}
			}
			isCheckStart = false;
		}
		
		//Rain of Death =================================================================================================
		if(rainOfDeath) {
			rainOfDeathTick ++;
			EntityTippedArrow e = new EntityTippedArrow(world, pos.getX()+.5, pos.getY()+1, pos.getZ()+.5);
			e.motionX = (Math.random()*4)-2;
			e.motionZ = (Math.random()*4)-2;
			e.motionY = 1.0F;
			world.spawnEntity(e);
			System.out.println("Fired arrow.");
		}
		if(rainOfDeathTick >= 20* 10) {
			rainOfDeath = false;
			rainOfDeathTick = 0;
		}
	}
	
	protected IBehaviorDispenseItem getBehavior(ItemStack stack)
    {
        return DISPENSE_BEHAVIOR_REGISTRY.getObject(stack.getItem());
    }
	
	private boolean shouldStart() {
		ArrayList<Item> inputs = new ArrayList<Item>();
		inputs.add(itemHandler.getStackInSlot(0).getItem());
		inputs.add(itemHandler.getStackInSlot(1).getItem());
		inputs.add(itemHandler.getStackInSlot(2).getItem());
		inputs.add(itemHandler.getStackInSlot(3).getItem());
		inputs.add(itemHandler.getStackInSlot(4).getItem());
		inputs.add(itemHandler.getStackInSlot(5).getItem());
		inputs.add(itemHandler.getStackInSlot(6).getItem());
		inputs.add(itemHandler.getStackInSlot(7).getItem());
		
		if(recipes.containsKey(inputs)) {
			System.out.println("Is a recipe");
			return true;
		}
		else {
			System.out.println("Not a recipe");
			return false;
		}
	}
	
	@Override
	public void readFromNBT(NBTTagCompound nbtTagCompound)
	{
		super.readFromNBT(nbtTagCompound);
		itemHandler.deserializeNBT(nbtTagCompound.getCompoundTag("ItemHandler"));
	}
	
	@Override
	public NBTTagCompound writeToNBT(NBTTagCompound nbtTagCompound)
	{
		super.writeToNBT(nbtTagCompound);
		nbtTagCompound.setTag("ItemHandler", itemHandler.serializeNBT());	
		return nbtTagCompound;
	}
	
	public EobItemHandler getItemHandler()
	{
		return itemHandler;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing)
	{
		if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
		{
			return (T) itemHandler;
		}

		return super.getCapability(capability, facing);
	}

	@Override
	public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing)
	{
		return false;
	}

	@Override
	public SPacketUpdateTileEntity getUpdatePacket()
	{
		return new SPacketUpdateTileEntity(pos, 0, getUpdateTag());
	}

	@Override
	public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
	{
		readFromNBT(pkt.getNbtCompound());
	}

	@Override
	public NBTTagCompound getUpdateTag()
	{
		return this.writeToNBT(new NBTTagCompound());
	}

	public void saveCraftingInfo(String text, boolean modeRecieved) {
		this.updateTile();
	}

	void updateTile(){
		world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 3);
		world.scheduleBlockUpdate(pos,this.getBlockType(),0,0);
		markDirty();
	}
}

 

In all honesty it is more than likely something obvious.

The seven became one and the one became two.

Link to comment
Share on other sites

I believe you have to call a function top set the arrow's damage amount. 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

This is how i create the arrow and fire it:

EntityTippedArrow e = new EntityTippedArrow(world, pos.getX()+.5, pos.getY()+1, pos.getZ()+.5);
e.motionX = (Math.random()*4)-2;
e.motionZ = (Math.random()*4)-2;
e.motionY = 1.0F;
world.spawnEntity(e);

The way the bow does it, it calls the shoot function, i also tried that but to no avail.

The seven became one and the one became two.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • So i know for a fact this has been asked before but Render stuff troubles me a little and i didnt find any answer for recent version. I have a custom nausea effect. Currently i add both my nausea effect and the vanilla one for the effect. But the problem is that when I open the inventory, both are listed, while I'd only want mine to show up (both in the inv and on the GUI)   I've arrived to the GameRender (on joined/net/minecraft/client) and also found shaders on client-extra/assets/minecraft/shaders/post and client-extra/assets/minecraft/shaders/program but I'm lost. I understand that its like a regular screen, where I'd render stuff "over" the game depending on data on the server, but If someone could point to the right client and server classes that i can read to see how i can manage this or any tip would be apreciated
    • Let me try and help you with love spells, traditional healing, native healing, fortune telling, witchcraft, psychic readings, black magic, voodoo, herbalist healing, or any other service your may desire within the realm of african native healing, the spirits and the ancestors. I am a sangoma and healer. I could help you to connect with the ancestors , interpret dreams, diagnose illness through divination with bones, and help you heal both physical and spiritual illness. We facilitate the deepening of your relationship to the spirit world and the ancestors. Working in partnership with one\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’s ancestors is a gift representing a close link with the spirit realm as a mediator between the worlds.*   Witchdoctors, or sorcerers, are often purveyors of mutis and charms that cause harm to people. we believe that we are here for only one purpose, to heal through love and compassion.*   African people share a common understanding of the importance of ancestors in daily life. When they have lost touch with their ancestors, illness may result or bad luck. Then a traditional healer, or sangoma, is sought out who may prescribe herbs, changes in lifestyle, a career change, or changes in relationships. The client may also be told to perform a ceremony or purification ritual to appease the ancestors.*   Let us solve your problems using powerful African traditional methods. We believe that our ancestors and spirits give us enlightenment, wisdom, divine guidance, enabling us to overcome obstacles holding your life back. Our knowledge has been passed down through centuries, being refined along the way from generation to generation. We believe in the occult, the paranormal, the spirit world, the mystic world.*   The services here are based on the African Tradition Value system/religion,where we believe the ancestors and spirits play a very important role in society. The ancestors and spirits give guidance and counsel in society. They could enable us to see into the future and give solutions to the problems affecting us. We use rituals, divination, spells, chants and prayers to enable us tackle the task before us.*   I have experience in helping and guiding many people from all over the world. My psychic abilities may help you answer and resolve many unanswered questions
    • Let me try and help you with love spells, traditional healing, native healing, fortune telling, witchcraft, psychic readings, black magic, voodoo, herbalist healing, or any other service your may desire within the realm of african native healing, the spirits and the ancestors. I am a sangoma and healer. I could help you to connect with the ancestors , interpret dreams, diagnose illness through divination with bones, and help you heal both physical and spiritual illness. We facilitate the deepening of your relationship to the spirit world and the ancestors. Working in partnership with one\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’s ancestors is a gift representing a close link with the spirit realm as a mediator between the worlds.*   Witchdoctors, or sorcerers, are often purveyors of mutis and charms that cause harm to people. we believe that we are here for only one purpose, to heal through love and compassion.*   African people share a common understanding of the importance of ancestors in daily life. When they have lost touch with their ancestors, illness may result or bad luck. Then a traditional healer, or sangoma, is sought out who may prescribe herbs, changes in lifestyle, a career change, or changes in relationships. The client may also be told to perform a ceremony or purification ritual to appease the ancestors.*   Let us solve your problems using powerful African traditional methods. We believe that our ancestors and spirits give us enlightenment, wisdom, divine guidance, enabling us to overcome obstacles holding your life back. Our knowledge has been passed down through centuries, being refined along the way from generation to generation. We believe in the occult, the paranormal, the spirit world, the mystic world.*   The services here are based on the African Tradition Value system/religion,where we believe the ancestors and spirits play a very important role in society. The ancestors and spirits give guidance and counsel in society. They could enable us to see into the future and give solutions to the problems affecting us. We use rituals, divination, spells, chants and prayers to enable us tackle the task before us.*   I have experience in helping and guiding many people from all over the world. My psychic abilities may help you answer and resolve many unanswered questions
    • Let me try and help you with love spells, traditional healing, native healing, fortune telling, witchcraft, psychic readings, black magic, voodoo, herbalist healing, or any other service your may desire within the realm of african native healing, the spirits and the ancestors. I am a sangoma and healer. I could help you to connect with the ancestors , interpret dreams, diagnose illness through divination with bones, and help you heal both physical and spiritual illness. We facilitate the deepening of your relationship to the spirit world and the ancestors. Working in partnership with one\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’s ancestors is a gift representing a close link with the spirit realm as a mediator between the worlds.*   Witchdoctors, or sorcerers, are often purveyors of mutis and charms that cause harm to people. we believe that we are here for only one purpose, to heal through love and compassion.*   African people share a common understanding of the importance of ancestors in daily life. When they have lost touch with their ancestors, illness may result or bad luck. Then a traditional healer, or sangoma, is sought out who may prescribe herbs, changes in lifestyle, a career change, or changes in relationships. The client may also be told to perform a ceremony or purification ritual to appease the ancestors.*   Let us solve your problems using powerful African traditional methods. We believe that our ancestors and spirits give us enlightenment, wisdom, divine guidance, enabling us to overcome obstacles holding your life back. Our knowledge has been passed down through centuries, being refined along the way from generation to generation. We believe in the occult, the paranormal, the spirit world, the mystic world.*   The services here are based on the African Tradition Value system/religion,where we believe the ancestors and spirits play a very important role in society. The ancestors and spirits give guidance and counsel in society. They could enable us to see into the future and give solutions to the problems affecting us. We use rituals, divination, spells, chants and prayers to enable us tackle the task before us.*   I have experience in helping and guiding many people from all over the world. My psychic abilities may help you answer and resolve many unanswered questions
    • Let me try and help you with love spells, traditional healing, native healing, fortune telling, witchcraft, psychic readings, black magic, voodoo, herbalist healing, or any other service your may desire within the realm of african native healing, the spirits and the ancestors. I am a sangoma and healer. I could help you to connect with the ancestors , interpret dreams, diagnose illness through divination with bones, and help you heal both physical and spiritual illness. We facilitate the deepening of your relationship to the spirit world and the ancestors. Working in partnership with one\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’s ancestors is a gift representing a close link with the spirit realm as a mediator between the worlds.*   Witchdoctors, or sorcerers, are often purveyors of mutis and charms that cause harm to people. we believe that we are here for only one purpose, to heal through love and compassion.*   African people share a common understanding of the importance of ancestors in daily life. When they have lost touch with their ancestors, illness may result or bad luck. Then a traditional healer, or sangoma, is sought out who may prescribe herbs, changes in lifestyle, a career change, or changes in relationships. The client may also be told to perform a ceremony or purification ritual to appease the ancestors.*   Let us solve your problems using powerful African traditional methods. We believe that our ancestors and spirits give us enlightenment, wisdom, divine guidance, enabling us to overcome obstacles holding your life back. Our knowledge has been passed down through centuries, being refined along the way from generation to generation. We believe in the occult, the paranormal, the spirit world, the mystic world.*   The services here are based on the African Tradition Value system/religion,where we believe the ancestors and spirits play a very important role in society. The ancestors and spirits give guidance and counsel in society. They could enable us to see into the future and give solutions to the problems affecting us. We use rituals, divination, spells, chants and prayers to enable us tackle the task before us.*   I have experience in helping and guiding many people from all over the world. My psychic abilities may help you answer and resolve many unanswered questions
  • Topics

×
×
  • Create New...

Important Information

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