Jump to content

[1.10.2] Thorns like behavior


Egietje

Recommended Posts

Hello

I want to make armor that if you wear the whole set you 'become' a hedgehog

With that I mean if you collide with another entity it will damage the other entity and damages the armor sort of like thorns

But how do I detect of the player that wears the set is collided with another entity and how do I damage the other entity and the armor?

Link to comment
Share on other sites

To detect if they are wearing the armor use onArmorTick and check if the players armor slots are of the armor Item. And I don't think there is a collision event so i would issue a pull request on forges github. Other thatn that you could use PlayerTickEvent and manually check if the player collides with another player.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

So I would do something like:

@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
	if(player.getItemStackFromSlot(EntityEquipmentSlot.HEAD) != null && player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).getItem().equals(KokkieItems.EGEL_HELMET)) {
		if(player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null && player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem().equals(KokkieItems.EGEL_CHESTPLATE)) {
			if(player.getItemStackFromSlot(EntityEquipmentSlot.LEGS) != null && player.getItemStackFromSlot(EntityEquipmentSlot.LEGS).getItem().equals(KokkieItems.EGEL_LEGGINGS)) {
				if(player.getItemStackFromSlot(EntityEquipmentSlot.FEET) != null && player.getItemStackFromSlot(EntityEquipmentSlot.FEET).getItem().equals(KokkieItems.EGEL_BOOTS)) {
					Entity entityInAABB = (Entity) world.getEntitiesWithinAABB(player.getClass(), player.getEntityBoundingBox());
					//Hurt entityInAABB
				}
			}
		}
	}
}

Link to comment
Share on other sites

The if statements are to check if the player is wearing all of the armor pieces of the set

How should I otherwise do that?

 

How can I hurt an entity?

With one if statement &&'s to use more than one boolean value. Also world.getEntitiesWithinAABB(...) should return a List<Entity> not a single Entity also instead of player.getClass() use EntityLivingBase.class.

 

*Edit Also to damage an entity living.attackEntityFromDamageSource(...)

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

If you want you can tidy it up by putting these conditions in a function that returns a boolean, where it returns false whenever any of the armor pieces isn't present. That won't make much of a change, however.

 

As for the hurting, check if the entity is instance of

EntityLivingBase

(super class for all entities with health even players) then use

EntityLivingBase#attackEntityFrom

with DamageSource being

DamageSource.causePlayerDamage(player)

Link to comment
Share on other sites

So it would be like this:

for(List<EntityLivingBase> entityInAABB = entitiesInAABB;entityInAABB.listIterator().hasNext();entityInAABB.listIterator().next()) {

					}

Not quite, you don't need to use iterator for a list at least if you are not removing anything. Instead a simple for loop would work.

The one you have down there will not work mainly because you don't create a variable for the next iteration. Though if you ever need to use an iterator look at some vanilla examples one off the top of my head would be FurnaceRecipes#getSmeltingResult(...).

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

No, I was f*cking around, but this works, right?

for (int i = 0; i < entitiesInAABB.size(); i++) {
						EntityLivingBase entityInAABB = entitiesInAABB.get(i);
						//Hurt entityInAABB
					}

Lol, yeah that will work.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Yeah but make sure that when you call getEntitiesWithinAABB(...) pass EntityLivingBase.class not Entity, because anything lower in the hierarchy is not damageable like that.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • https://drive.google.com/file/d/1M0EG-c5yfRd08DSnE5HVQNCu2v0YtA7A/view?usp=sharing  
    • so im not sure if your still watching this TileEntity but once we loaded a FTB modpack we wanted to run on the server it no longer seems to run. The console opens like normal but we've been sitting here for like a little over an hour and the server screen has not yet opened. Should we just keep waiting at this point?
    • I have now easily fixed the duplication error present, I was just not looking.   I have been working for the past half hour to try and fix another error present, this time with the Creative Mode Tab.   I have changed some things around to get where I am currently. (ModFoods to ModDrinks*) and it cannot find the symbol ".get" at the end of the code. *The custom class you recommended pOutput.accept(ModDrinks.ORANGE_JUICE.get()); I think the point I am at currently is the closest I have to how it should be but because I am not as experienced with java I would not know.  I have also removed ORANGE_JUICE and LEMON_JUICE from the ModFoods class, to avoid confliction. I do hope all this can be fully resolved soon.  
    • [SOLVED]  public class RenderGUIHandler { @SubscribeEvent public void renderGUI(RenderGameOverlayEvent.Text event){ Client.hud.draw(); } } As I was playing around a little with the code, i found out about an option to change The RenderGameOverlayEvent.Post to RenderGameOverlayEvent.Text
    • public class HUD { public Minecraft mc = Minecraft.getMinecraft(); public static class ModuleComparator implements Comparator<Module>{ @Override public int compare(Module o1, Module o2) { if (Minecraft.getMinecraft().fontRendererObj.getStringWidth(o1.name) > Minecraft.getMinecraft().fontRendererObj.getStringWidth(o2.name)){ return -1; } if (Minecraft.getMinecraft().fontRendererObj.getStringWidth(o1.name) < Minecraft.getMinecraft().fontRendererObj.getStringWidth(o2.name)){ return 1; } return 0; } } public void draw(){ ScaledResolution sr = new ScaledResolution(mc); FontRenderer fr = mc.fontRendererObj; Collections.sort(Client.modules, new ModuleComparator()); GlStateManager.pushMatrix(); GlStateManager.translate(4,4,0); GlStateManager.scale(1.5,1.5,1); GlStateManager.translate(-4, -4, 0); fr.drawString("Skyline", 10, 10, -1); GlStateManager.popMatrix(); int count = 0; for (Module m : Client.modules){ if (!m.toggled || m.name.equals("TabGUI")) continue; int offset = count* (fr.FONT_HEIGHT + 6); GL11.glTranslated(0.0f, 0.0f, -1.0f); Gui.drawRect(sr.getScaledWidth() - fr.getStringWidth(m.name) - 10, offset, sr.getScaledWidth() - fr.getStringWidth(m.name) - 8, 6 + fr.FONT_HEIGHT + offset, -1); Gui.drawRect(sr.getScaledWidth() - fr.getStringWidth(m.name) - 8, offset, sr.getScaledWidth(), 6 + fr.FONT_HEIGHT + offset, 0x90000000); fr.drawString(m.name, sr.getScaledWidth() - fr.getStringWidth(m.name) - 4, offset + 4, -1); count++; } Client.onEvent(new EventRenderGUI()); } } I have just recently stumbled upon this Problem, where the HudRenderer renders the wrong section of the textures and therefore completely destroys the Minecraft Armour and Hunger Bar. I am currently thinking if it is an issue with the DrawRect changing something it shouldn't. But I couldn't find anything about it. (To keep things Clean, the function is Called from another file) public class RenderGUIHandler { @SubscribeEvent public void renderGUI(RenderGameOverlayEvent.Post event){ Client.hud.draw(); } } Any help would be greatly appreciated  
  • Topics

×
×
  • Create New...

Important Information

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