Jump to content

Merthew

Members
  • Posts

    128
  • Joined

  • Last visited

Everything posted by Merthew

  1. That didn't work. Caused the code to not even run.
  2. I have created a custom tileentity that on pressing a button in the center, and with all slots empty, it should change the weather to clear. However, nothing happens... Code File: Any help would be apreciated.
  3. I am just going to try to do it a different way, i have been looking at this for way too long and finding nothing. Thanks for your help though.
  4. I don't need to know why the player gets hurt, i know that it is from fall damage. I need to know why the value for fall damage is getting saved somewhere and reintroduced after i try and set it to zero.
  5. Still not able to get it working.
  6. I put a sysout statement at the end of the method and it would read 0.0 when the player was either not moving or just moving on the horizontal axis. However, when vertical motion happened it would keep the last value and add to it. That and the player takes fall damage anytime they land if they flew above 3 or 4 blocks.
  7. I have made a custom perk system (somewhat) and one of the things is creative flight. However, when using the creative flight the fall distance is not reset to zero. My guess is it is something to do with me not being smart. Relevant file: PerkHandler,java package merthew.mod.util.handlers; import merthew.mod.capability.perks.IPerks; import merthew.mod.capability.perks.PerksProvider; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; import net.minecraft.potion.PotionEffect; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; public class PerkHandler { @SubscribeEvent public void perkEffects(TickEvent.PlayerTickEvent event) { EntityPlayer player = event.player; IPerks perks = player.getCapability(PerksProvider.PERKS, null); if(perks != null) { //Fly========================================================================================\\ boolean fly = false; if(perks.getPerk("fly") >= 1) { fly = true; event.player.fallDistance = 0.0f; } else { fly = false; } if(fly || event.player.isCreative() || event.player.isSpectator()) { event.player.capabilities.allowFlying = true; event.player.fallDistance = 0.0f; } else { fly = false; event.player.capabilities.allowFlying = false; event.player.capabilities.isFlying = false; } //Strength========================================================================================\\ if(perks.getPerk("strength") > 0) { player.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 10, perks.getPerk("strength"), false, false)); } } } }
  8. Fixed it. registration of the capability was deprecated and some of the code was slightly off.
  9. It should be in CapabilityHandler.java
  10. Sorry about that, it should be up now.
  11. I am trying to have a capability that is for detecting if a player is gliding with my custom glider. Currently, i dont think that it is attaching to the player right. Any help would be apreciated. Code: https://github.com/Merthew/Empire-Of-Blood Files: Main.java, Gliding.java, IGliding.java, GlidingProvider.java, GlidingStorage.java, ItemGlider.java, CapabilityHandler.java, GlidingHandler.java
  12. I made a custom glider style thing and i want to change the player model orientation when you are gliding with it, similar to how the elytra works. How would i go about doing this?
  13. This is what i came up with, any thoughts? @SubscribeEvent public void bloodTotem(LivingSpawnEvent event) { World world = event.getWorld(); double range = 32.0; for(int i = 0; i < world.loadedTileEntityList.size(); i ++) { if(world.loadedTileEntityList.get(i) instanceof TileEntityBloodTotem) { BlockPos pos = world.loadedTileEntityList.get(i).getPos(); if(pos.getDistance((int)event.getX(), (int)event.getY(), (int)event.getZ()) <= range) { event.setResult(Result.DENY); } } } }
  14. Not sure if it is the best way, but using onUpdate and checking the stack's slot index may work. May also cause way too much lag...
  15. What would be the best way to stop mobs from spawning around a custom block? Would i use a ticking tileentity or forge events?
  16. Still not working. Getting this from extra utils 2
  17. The problem is that i don't know how to not use static i may just be missing some logic or knowledge of java. *Never mind, i fixed it. sorry for my incompetence
  18. Currently I have two structures that i am trying to generate, but only the one i put in code later generates. Would i need to do them in separate gen classes? Code: https://github.com/Merthew/Empire-Of-Blood Current File: WorldGenCustomStructures
  19. Could not get loot tables to work and managed to fix the issue. Also will fix the string thing, now i just need to get the randomness of the generation to work right.
  20. I currently have two structures that generate. When I started to add loot to the second, holy_altar, it began to crash on world generation. This is the console output that I am getting: I am pretty sure that lag is being caused between ticks and causing the game to crash. What would be a better way to write this code? Code: https://github.com/Merthew/Empire-Of-Blood Current Files: WorldGenStructure, WorldGenCustomStructure
  21. I am getting method not found errors
  22. How would i get other mods to work in the modding environment? Like if i wanted jei or journeymap for testing.
  23. How would I get all the entites within a box around my custom block with a ticking tileentity? I am currently trying this: public class TileEntityBloodCollector extends TileEntity implements ITickable{ private final EobItemHandler itemHandler; int blood; int cap = 10000; public TileEntityBloodCollector() { super(); itemHandler = new EobItemHandler(1); } @Override public void update() { BlockPos pos = this.getPos(); boolean isChanged = false; int ticks = 0; ItemStack stack0 = itemHandler.getStackInSlot(0); if(!this.world.isRemote) { if(stack0.hasTagCompound()) { ItemStack stack = itemHandler.getStackInSlot(2); NBTTagCompound nbt; if (stack.hasTagCompound()) { nbt = stack.getTagCompound(); } else { nbt = new NBTTagCompound(); } if(nbt.hasKey("blood")) { int currBlood = nbt.getInteger("blood"); int possBlood = nbt.getInteger("cap") - currBlood; if(possBlood <= blood) { nbt.setInteger("blood", possBlood + currBlood); blood -= possBlood; } else { nbt.setInteger("blood", blood + currBlood); blood = 0; } stack.setTagCompound(nbt); } isChanged = true; } List<Entity> entitys = this.getWorld().getEntitiesWithinAABB(EntityLiving.class, new AxisAlignedBB(pos.getX()-5, pos.getY()-2, pos.getZ()-5, pos.getX()+5, pos.getY()+2, pos.getZ()+5)); for(Entity e : entitys) { if(!(e instanceof AbstractSkeleton) && !(e instanceof EntitySlime) && !(e instanceof EntityMagmaCube) && (e instanceof EntityCreature) && ticks >= 21) { blood += 10; e.attackEntityFrom(DamageSource.MAGIC, 1); isChanged = true; ticks = 0; } } ticks ++; } if(isChanged) { this.updateTile(); } } @Override public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); itemHandler.deserializeNBT(nbtTagCompound.getCompoundTag("ItemHandler")); this.cap = nbtTagCompound.getInteger("cap"); this.blood = nbtTagCompound.getInteger("blood"); } @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTagCompound) { super.writeToNBT(nbtTagCompound); nbtTagCompound.setTag("ItemHandler", itemHandler.serializeNBT()); nbtTagCompound.setDouble("cap", cap); nbtTagCompound.setDouble("blood", blood); return nbtTagCompound; } void updateTile(){ world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 3); world.scheduleBlockUpdate(pos,this.getBlockType(),0,0); markDirty(); } 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 capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); } @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()); } Code: https://github.com/Merthew/Empire-Of-Blood/ Currently working on: BlockBloodCollector
  24. Thanks
×
×
  • Create New...

Important Information

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