-
Posts
307 -
Joined
-
Last visited
Posts posted by Tschipp
-
-
4 minutes ago, Abastro said:
If I recall correctly, the second parameter of the drain method is about whether it'll be simulated(to check the validity) or the change is actually applied. So it should be false in your csse.
I've tried both true and false, still doesn't empty the bucket.
-
Thanks. One more thing:
This doesn't seem to drain the bucket:
FluidUtil.getFluidHandler(heldItem).drain(1000, true);
the FluidHandler isn't null, i do that check beforehand. What am I missing?
-
Thanks, was wondering what FLUID_HANDLER_ITEM was for... Also didn't know about FluidUtil. Is there also a ItemHandlerUtil of some sort for ItemStackHandlers?
-
I'm trying to check if an ItemStack has the FluidHandler capability.
For that I tried using this:
boolean hasCap = stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
The ItemStack passed was a ItemWaterBucket. I've also tried it using forge filled buckets, but both alway return false. Am I checking for the wrong capability?
-
One quick question: how do i get an itemstack of the bucket containing the fluid?
-
thanks for the quick response
-
I'm trying to get a forge bucket that was created using FluidRegistry.addBucketForFluid to a custom creative tab for my mod. Can that be done?
Also, can other things about the bucket be modified? Like the texture or the name?
-
Perfect, thanks
-
Is there an event that fires when two animals are bred, meaning they have a baby? I need to have access to the parent entities and the resulting baby, because I want to make the baby inherit some traits from the parents.
-
Thanks, that seemed to do it, it doesn't fire for spawneggs though. Is there an other event for that?
-
On 27.4.2017 at 6:27 PM, Choonster said:
LivingSpawnEvent.SpecialSpawn is fired just before an entity is spawned by WorldEntitySpawner (passive spawns) or MobSpawnerBaseLogic (monster spawners).
I see, but does that mean that hostile mob spawns are not included?
-
I'm looking for an Event that fires whenever an Entity spawns newly in the world, meaning not when the players enters its loading distance or the world is loaded, only when it spawns fresh.
Does such an Event exist?
-
Is there an event that gets triggered when the player list is shown (tab is pressed)? And is there a way to modify the list?
-
I have an item that changes its appearance based on nbt. For that I made a custom IBakedModel with a custom ItemOverrideList
What i now do in the ItemOverrideList#handleItemState method is create a new SimpleBakedModel, that I create from the parent model of an itemstack. I know sounds confusing, let's just show the code:
ItemOverrideList:
public static class OverrideList extends ItemOverrideList { public OverrideList(List<ItemOverride> overridesIn) { super(overridesIn); } @Override public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) { if(stack.hasTagCompound() && stack.getTagCompound().hasKey("block") && stack.getTagCompound().hasKey("meta")) { Block block = Block.getBlockFromName(stack.getTagCompound().getString("block")); int meta = stack.getTagCompound().getInteger("meta"); IBlockState state = block.getDefaultState(); meta = meta - 12; ItemStack blockstack = new ItemStack(block, 1, meta); IBakedModel parentmodel = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(blockstack); TextureAtlasSprite side = parentmodel.getParticleTexture(); Map<EnumFacing, List<BakedQuad>> map = new HashMap<EnumFacing, List<BakedQuad>>(); List<BakedQuad> quadsup = parentmodel.getQuads(state, EnumFacing.UP, 0); BakedQuadRetextured up = new BakedQuadRetextured(quadsup.get(0), side); quadsup.set(0,up); List<BakedQuad> quadsdown = parentmodel.getQuads(state, EnumFacing.DOWN, 0); BakedQuadRetextured down = new BakedQuadRetextured(quadsdown.get(0), side); quadsdown.set(0,down); map.put(EnumFacing.DOWN, quadsdown); map.put(EnumFacing.UP, quadsup); map.put(EnumFacing.NORTH, parentmodel.getQuads(state, EnumFacing.NORTH, 1)); map.put(EnumFacing.SOUTH, parentmodel.getQuads(state, EnumFacing.SOUTH, 1)); map.put(EnumFacing.WEST, parentmodel.getQuads(state, EnumFacing.WEST, 1)); map.put(EnumFacing.EAST, parentmodel.getQuads(state, EnumFacing.EAST, 1)); SimpleBakedModel model = new SimpleBakedModel(new ArrayList(), map, parentmodel.isAmbientOcclusion(), parentmodel.isGui3d(), side, parentmodel.getItemCameraTransforms(), ItemOverrideList.NONE); return model; } return Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(new ItemStack(Blocks.LOG)); } }
So what's happening is I'm getting a block with metadata stored in nbt of the itemstack. Then I create an ItemStack from that block and metatdata. Then I get the BakedModel for that ItemStack, and also extract the particle texture. Then I create a new map which contains all the BakedQuads. The BakedQuads I get from the parentModel. I also edit the top and bottom quad, to change the texture, so I replace them in the list with a BakedQuadRetextured. Finally, I create the SimpleBakedModel and return it.
The problem now is this:
https://gyazo.com/29de5fec9915a801d0f4dae029bc37c4
First of all, it cycles through every texture for the top quad. The bottom quad remains unchanged.
It also changes the top quad for vanilla log blocks, idk how that's happening.
I'm applying the BakedModel in the ModelBakeEvent:
@SubscribeEvent public void onModelBake(ModelBakeEvent event) { Object object = event.getModelRegistry().getObject(new ModelResourceLocation("barkifier:barkified_log", "inventory")); if (object instanceof IBakedModel) { IBakedModel existingModel = (IBakedModel)object; BarkifiedLogsRendering.Model customModel = new BarkifiedLogsRendering.Model(existingModel); event.getModelRegistry().putObject(new ModelResourceLocation("barkifier:barkified_log", "inventory"), customModel); } }
Also, my IBakedModel:
public static class Model implements IPerspectiveAwareModel { private IBakedModel base; private OverrideList overrides; public Model(IBakedModel base) { this.base = base; this.overrides = new OverrideList(Collections.EMPTY_LIST); } @Override public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) { return base.getQuads(state, side, rand); } @Override public boolean isAmbientOcclusion() { return base.isAmbientOcclusion(); } @Override public boolean isGui3d() { return base.isGui3d(); } @Override public boolean isBuiltInRenderer() { return base.isBuiltInRenderer(); } @Override public TextureAtlasSprite getParticleTexture() { return base.getParticleTexture(); } @Override public ItemCameraTransforms getItemCameraTransforms() { return base.getItemCameraTransforms(); } @Override public ItemOverrideList getOverrides() { return overrides; } @Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { if (base instanceof IPerspectiveAwareModel) { Matrix4f matrix4f = ((IPerspectiveAwareModel)base).handlePerspective(cameraTransformType).getRight(); return Pair.of(this, matrix4f); } else { // If the base model isn't an IPerspectiveAware, we'll need to generate the correct matrix ourselves using the // ItemCameraTransforms. ItemCameraTransforms itemCameraTransforms = base.getItemCameraTransforms(); ItemTransformVec3f itemTransformVec3f = itemCameraTransforms.getTransform(cameraTransformType); TRSRTransformation tr = new TRSRTransformation(itemTransformVec3f); Matrix4f mat = null; if (tr != null) { // && tr != TRSRTransformation.identity()) { mat = tr.getMatrix(); } // The TRSRTransformation for vanilla items have blockCenterToCorner() applied, however handlePerspective // reverses it back again with blockCornerToCenter(). So we don't need to apply it here. return Pair.of(this, mat); } } }
I really hope someone can help me with this, I cannot explain how this is happening.
-
18 minutes ago, larsgerrits said:
It's an old, bad API which is still used by Minecraft itself, while capabilities are added by Forge to offer much better compatibility between mods. If you still use IInventory/ISidedInventory, most mods wouldn't know how to interact with your inventories, and can't be used in automation.
Ok, I see. But in this case, automation really doesn't matter. The block just gives you some text information about the item that you put in, so it's only useable by players. I'll still take a look at the capability thing, in the long run it seems less complicated.
-
6 hours ago, diesieben07 said:
Don't use ISidedInventory, use the IItemHandler capability.
But then I have to rewrite everything...
Why shouldn't I use ISidedInventory? Because it's old?
-
9 hours ago, Kokkie said:
Why all this? You can also just check once if it isn't EnumFacing.DOWN...
Whoops
But still, I removed all this and just return true all the time, I also added a print statement... nothing. The method is supposed to be executed when a hopper tries to insert an item into the machine, right? Becasue the ISidedInventory#canExtractItem method gets executed when a hopper tries to pull items out of it...
-
7 hours ago, Choonster said:
They can, using AnimationModelBase. This also allows the model to be animated with Forge's baked model animation system.
Oh. I guess so, learned something new
-
I want to make it so that a slot from my machine is accessable from up and all the sides, but the ISidedInventory#canInsertItem method doesn't seem to get called... ever. I've checked with the debug tool.
This is my method, but as I said it isn't even being called.. Am I understanding something wrong?
@Override public boolean canInsertItem(int index, ItemStack stack, EnumFacing direction) { return (direction == EnumFacing.EAST || direction == EnumFacing.NORTH || direction == EnumFacing.SOUTH || direction == EnumFacing.WEST || direction == EnumFacing.UP) && index == 9; }
-
Well, seems like all I had to do is make it a submodel of something... It works now!
-
-
49 minutes ago, recneps said:
I'd just put it in the code right before it checks if you're wearing the armour.. That way it sets it to 0 each time and then increases it afterwards.
Hm. It doesn't seem to be possible to set the attributes for a player, it's only possible to get them. Did you have anything other in mind?
EDIT: I figured it out, the attribute had no valid UUID
-
23 minutes ago, recneps said:
It seems to me like the error is it not resetting the knockback resistance of the player. It increases it by .25 if the player is wearing the armour, but does it ever set it to 0? Or does it just increase it each time the code runs?
No, I don't set it to 0 ever. I thought somethink like that was done automatically, when the armor gets unequipped. Like when you're holding a sword that boosts your speed, switching off that sword also removes your speed. But I can try and see if that's the reason.
-
[1.11.2] FluidHandler capability on buckets
in Modder Support
Posted
getFluidHandler returns a IFluidHandlerItem, which isn't null. drain returns a FluidStack, the stack that supposedly was drained, also correct.