-
Posts
138 -
Joined
-
Last visited
Everything posted by BlockyPenguin
-
[Solved] Loop through all entities standing on block
BlockyPenguin replied to BlockyPenguin's topic in Modder Support
Ah, that works! Brilliant, thank you! -
[Solved] Loop through all entities standing on block
BlockyPenguin replied to BlockyPenguin's topic in Modder Support
Ah, ok, thanks! I'l take a look now -
[Solved] Loop through all entities standing on block
BlockyPenguin replied to BlockyPenguin's topic in Modder Support
Ah, nice! I hadn't thought about that! Thanks! -
[Solved] Loop through all entities standing on block
BlockyPenguin replied to BlockyPenguin's topic in Modder Support
Also, as a sidenote, all aesthetics and nice-feeling timings aside, how effective is having a counter at decreasing server lag? -
[Solved] Loop through all entities standing on block
BlockyPenguin replied to BlockyPenguin's topic in Modder Support
Ok package com.blockypenguin.labkit.tileentities; import ... public class HealthCollectorTile extends TileEntity implements ITickableTileEntity, INamedContainerProvider { private LazyOptional<IEnergyStorage> energy = LazyOptional.of(this::createEnergy); int counter = 10; // 20 ticks is approximately one second, therefore 10 ticks is approximately half a second. BlockState newBlockState; int collectedHealth = 0; Mode mode = Mode.DAMAGE_HEAL; AxisAlignedBB aabbAbove = new AxisAlignedBB(pos.up()); public HealthCollectorTile() { super(ModTiles.HEALTH_COLLECTOR_TILE); } @Override public void tick() { if(world.isRemote()) return; if (counter <= 0) { for (LivingEntity ent : world.getEntitiesWithinAABB(LivingEntity.class, aabbAbove)) { if(ent.getHealth() > 1) { ent.setHealth(ent.getHealth() - 1); ent.performHurtAnimation(); energy.ifPresent(e -> ((CustomEnergyStorage)e).subtractEnergy(100)); collectedHealth++; } } counter = 10; }else { counter--; markDirty(); } energy.ifPresent(e -> { if(e.getEnergyStored() < 0) { ((CustomEnergyStorage) e).setEnergy(0); } }); } // Get data from the NBT @SuppressWarnings("unchecked") @Override public void read(CompoundNBT tag) { CompoundNBT energyTag = tag.getCompound("energy"); energy.ifPresent(e -> ((INBTSerializable<CompoundNBT>) e).deserializeNBT(energyTag)); counter = tag.getInt("counter"); collectedHealth = tag.getInt("collectedHealth"); super.read(tag); } // Send data to the NBT @SuppressWarnings("unchecked") @Override public CompoundNBT write(CompoundNBT tag) { energy.ifPresent(h -> { CompoundNBT compound = ((INBTSerializable<CompoundNBT>) h).serializeNBT(); tag.put("energy", compound); }); tag.putInt("counter", counter); tag.putInt("collectedHealth", collectedHealth); return super.write(tag); } // When creating the energy storage, use CustomEnergyStorage, with a maximum capacity of 100,000FE private IEnergyStorage createEnergy() { return new CustomEnergyStorage(100000, 0); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { if (cap == CapabilityEnergy.ENERGY) { return energy.cast(); } return super.getCapability(cap, side); } @Override public ITextComponent getDisplayName() { return new TranslationTextComponent("container.labkit.health_collector"); } @Nullable @Override public Container createMenu(int i, PlayerInventory playerInventory, PlayerEntity playerEntity) { return new HealthCollectorContainer(i, world, pos, playerInventory, playerEntity); } public static enum Mode { DAMAGE_HEAL, PERMANENT } } I know Mode doesn't do anything, that's coming later. My goal is to damage the entity every 10 ticks, so long as the entity has more than half a heart of health, and save the amount of damage dealt to colledtedHealth. -
So, I have a block with a TileEntity. All's working fine, except for the main purpose of said TileEntity. I want it to loop through each entity standing on top of the block, and run some code for each one. It doesn't. I define an AxisAlignedBB: AxisAlignedBB aabbAbove = new AxisAlignedBB(pos.up()); and use it in my tick() method: for (LivingEntity ent : world.getEntitiesWithinAABB(LivingEntity.class, aabbAbove)) { if(ent.getHealth() > 1) { ent.setHealth(ent.getHealth() - 1); ent.performHurtAnimation(); collectedHealth++; } } but the above for loop never fires... any ideas? Thanks, ~Blocky
-
[1.14.4] How to use a player's face as an item texture
BlockyPenguin replied to BlockyPenguin's topic in Modder Support
Bump -
[1.14.4] How to use a player's face as an item texture
BlockyPenguin replied to BlockyPenguin's topic in Modder Support
Sorry ? -
[1.14.4] How to use a player's face as an item texture
BlockyPenguin replied to BlockyPenguin's topic in Modder Support
bump? -
[1.14.4] How to use a player's face as an item texture
BlockyPenguin replied to BlockyPenguin's topic in Modder Support
Okay, so, I've seemingly not done something right here... I can start MC and all perfectly fine, but when i /give myself the item, the game instanly crashes. no "Saving World" first or anything, just an instant crash. This is the crash report: My guess is I'm not rendering it properly. Here's my code: MiniPlayer.java: MiniPlayerRenderer.java: TwoDimensionalFaceModel.java: Where am I going wrong? Thanks, ~BP -
[1.14.4] How to use a player's face as an item texture
BlockyPenguin replied to BlockyPenguin's topic in Modder Support
Ah ok, thanks Anyway, having now looked at SkullTileEntityRenderer, I'm not entirely sure what I need to keep. I'm new to modding in general and haven't dabbled at all in custom renderers, do you have any help or tips? Thanks, ~BP -
[1.14.4] How to use a player's face as an item texture
BlockyPenguin replied to BlockyPenguin's topic in Modder Support
Ah, no, I saw SkullTileEntity, but not SkullTileEntityRenderer! I'll be sure to take a look. By that last part, I'm guessing you mean that because it is a BlockItem, it can access the tile entity even though it hasn't been placed yet. Thanks! P.S. How do you create inline code blocks in a post? -
Hi all, thanks for your answers, but from what I can understand, this will only disable the creation of my splash and lingering potions, whereas I don't want them in the game at all. @TheGreyGhost, I've had a look, and they all seem to be relating to the brewing recipe, rather than the potion itself actually existing. Is it even possible to not have the variants? I've also discovered that it's creating tipped arrows for the potion as well... Sorry for the confusion.
-
Hi! I'd like to know how to use a player's face as the texture for an item. I know this is possible due to player heads existing in-game. I have looked through the player head code, but I can't seem to understand it, as it calls methods from tile entities... how is that possible when it's an item? To be more specific, I'm not looking for a player head duplicate, just a 2D item that has the same texture as a player's face. Thanks, ~BP
-
I was trying to check if what was in the input slot is the correct input (a water bottle)... I'm guessing that's not what it does? I couldn't find much up-to-date documentation on brewing, sorry if this is an obvious solution. EDIT: So I've done some digging and I think what you saying is to check if the input is a splash water bottle, right? Please bear in mind, I'd like these potions to completely disappear from the game, even the creative inventory. If I'm right, making sure that the input is not a splash potion won't remove it from the registry.
-
@Draco18s, thanks for your reply. I now have this code: @SubscribeEvent public void onLootLoad(LootTableLoadEvent e) { LOGGER.info("LOOT IS LOADING"); if(e.getName().equals(new ResourceLocation("minecraft", "chests/simple_dungeon"))) { e.getTable().addPool(LootPool.builder().addEntry(TableLootEntry.builder(new ResourceLocation(MODID, "inject/simple_dungeon"))).build()); } } But it still doesn't work. In fact "LOOT IS LOADING" never gets sent to the console! Why is this? My json file is in "resources/data/labkit/loot_tables/inject/simple_dungeon.json", that seems fine...
-
So I want to add an item to the vanilla loot table "simple_dungeon", but whatever I try, it doesn't work... Any help appreciated. EDIT: I now have this code: @SubscribeEvent public void onLootLoad(LootTableLoadEvent e) { if (e.getName().toString().equals("minecraft:chests/simple_dungeon")) { LootPool pool = LootPool.builder().rolls(ConstantRange.of(1)).addEntry(ItemLootEntry.builder(ModItems.GOLDEN_FEATHER).weight(25)).addEntry(ItemLootEntry.builder(Items.AIR).weight(75)).build(); e.getTable().addPool(pool); } } but it still doesn't add it to the the loot table. I can check the loot tables with /loot, but I also added in some messages to be printed to the console when onLootLoad was run, and they never got printed. What's going on?