Compare commits

..
4 Commits
Author SHA1 Message Date
Alex VermetteandAlex Vermette d6fa8d8b74 fix: implement stacked block slab (#127)
Co-authored-by: Alex Vermette <[email protected]>
2026-07-27 13:20:40 -04:00
UltraProdigy 704861b666 Delete Forestry CONTRIBUTING.md (#126) 2026-07-04 19:02:06 +00:00
Algent db25dcce48 Dupe Fix - Make bag logic more lag resistant (#121) 2026-07-04 18:57:41 +00:00
FourIsTheNumber 4b364a93db Use extended interface (#125) 2026-07-01 18:27:50 -04:00
10 changed files with 54 additions and 50 deletions

No files matched your search

-29
View File
@@ -1,29 +0,0 @@
How to submit a bug report to Forestry
====================================
Please make sure the bug has not already been reported by [searching the issues](https://github.com/ForestryMC/ForestryMC/issues?q=is%3Aissue).
If you can, see if the bug still happens with the latest unstable build.
[The latest unstable builds are available here](http://jenkins.ic2.player.to/job/Forestry_Dev/)
For crashes, you must post a link to the full crash report.
[gist.github.com](gist.github.com) or [pastebin.com](www.pastebin.com) are good places to upload them.
Full crash reports are located in [the minecraft data folder](http://hopper.minecraft.net/help/finding-minecraft-data-folder/), in "crash-reports".
Thank you for reporting bugs!
How to contribute to Forestry
====================================
### Contributor License Agreement
Before pull requests can be accepted, the contributor needs to sign a contributor license agreement. (Essentially giving a license for using his code and/or media and for re-licensing it, for details read the agreement linked below.)
### How do I sign?
To keep the hassle for everyone involved to a minimum, Forestry uses CLAHub to manage the agreements. To get started, <a href="https://www.clahub.com/agreements/ForestryMC/ForestryMC">sign the Contributor License Agreement</a>.
### Why is this needed?
Without CLAs it at some point becomes essentially impossible to change the license of a project which accepts contributions from third parties. Without an explicit agreement every contributor would still own the copyright to his code. So as long as it (or parts of it) remain in the code base, he would have to agree to every license change. If enough time has passed, there may be dozens, perhaps even hundreds of contributors involved and it will be very hard to track down each and every one of them and get them to agree on a new license.
This would make it impossible to change the license to a more permissive one at a later date, so the code would be locked into CC BY-NC-ND 3.0 until it passes into the public domain about a hundred years from now. This situation is to be avoided and that’s why you are being bothered with this CLA.
@@ -25,19 +25,6 @@ public interface IArmorApiarist {
*/
boolean protectEntity(EntityLivingBase entity, ItemStack armor, String cause, boolean doProtect);
/**
* Called to determine how many pieces an armor "counts for". For instance, if this returns 4, the single piece will
* act as full protection.
*
* @param entity Entity being attacked
* @param armor Armor item
* @param cause Optional cause of attack, such as a bee effect identifier
* @return Amount of effective protected slots
*/
default int getProtectionCount(EntityLivingBase entity, ItemStack armor, String cause) {
return 1;
}
/**
* Called when the apiarist's armor acts as protection against an attack.
*
@@ -0,0 +1,20 @@
package forestry.api.apiculture;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
public interface IArmorApiaristMulti extends IArmorApiarist {
/**
* Called to determine how many pieces an armor "counts for". For instance, if this returns 4, the single piece will
* act as full protection.
*
* @param entity Entity being attacked
* @param armor Armor item
* @param cause Optional cause of attack, such as a bee effect identifier
* @return Amount of effective protected slots
*/
default int getProtectionCount(EntityLivingBase entity, ItemStack armor, String cause) {
return 1;
}
}
@@ -10,10 +10,12 @@ package forestry.apiculture;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.IArmorApiarist;
import forestry.api.apiculture.IArmorApiaristHelper;
import forestry.api.apiculture.IArmorApiaristMulti;
public class ArmorApiaristHelper implements IArmorApiaristHelper {
@@ -40,7 +42,9 @@ public class ArmorApiaristHelper implements IArmorApiaristHelper {
for (int i = 1; i <= 4; i++) {
ItemStack armorItem = entity.getEquipmentInSlot(i);
if (isArmorApiarist(armorItem, entity, cause, doProtect)) {
count += ((IArmorApiarist) armorItem.getItem()).getProtectionCount(entity, armorItem, cause);
Item item = armorItem.getItem();
if (item instanceof IArmorApiaristMulti am) count += am.getProtectionCount(entity, armorItem, cause);
else count++;
}
}
@@ -16,8 +16,8 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@@ -84,7 +84,8 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
@Override
protected ItemStack createStackedBlock(int meta) {
return new ItemStack(Blocks.wooden_slab, 2, meta & 7);
Item item = Item.getItemFromBlock(this);
return item != null ? new ItemStack(item, 2, 0) : null;
}
@Override
@@ -107,6 +108,18 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
return new TileWood();
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
// Special case for double slabs placed by building mods (e.g., MatterManipulator)
if (stack == null) return;
int damage = stack.getItemDamage();
if (damage < 0 || damage >= EnumWoodType.VALUES.length) return;
TileWood tile = TileWood.getWoodTile(world, x, y, z);
if (tile != null) {
tile.setWoodType(EnumWoodType.VALUES[damage]);
}
}
/* PROPERTIES */
@Override
public final ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
@@ -87,7 +87,7 @@ public abstract class ItemInventory implements IInventory, IFilterSlotDelegate {
public boolean isParentItemEquipped() {
return switch (location.type()) {
case HELD_BY_PLAYER, UNKNOWN -> isSameItemInventory(player.getCurrentEquippedItem(), parent);
case PLAYER_INVENTORY -> true;
case PLAYER_INVENTORY -> isSameItemInventory(player.inventory.getStackInSlot(location.slotIdx()), parent);
};
}
@@ -95,6 +95,10 @@ public abstract class ItemInventory implements IInventory, IFilterSlotDelegate {
return player;
}
public ItemLocation getLocation() {
return location;
}
public boolean isParentItemInventory(ItemStack itemStack) {
ItemStack parent = getParent();
return isSameItemInventory(parent, itemStack);
@@ -33,7 +33,7 @@ public abstract class ItemWithGui extends ItemForestry implements IGuiHandlerIte
}
protected void openGui(EntityPlayer entityplayer) {
GuiHandler.openGui(entityplayer, this);
GuiHandler.openGui(entityplayer, this, (short) 0, entityplayer.inventory.currentItem);
}
@Override
@@ -28,6 +28,11 @@ public class ItemInventoryBackpackPaged extends ItemInventoryBackpack implements
@Override
public void flipPage(EntityPlayer player, short page) {
GuiHandler.openGui(player, backpackNaturalist, page);
ItemLocation loc = getLocation();
if (loc.type() == ItemLocation.Type.PLAYER_INVENTORY) {
GuiHandler.openGui(player, backpackNaturalist, page, loc.slotIdx());
} else {
GuiHandler.openGui(player, backpackNaturalist, page);
}
}
}
@@ -72,7 +72,7 @@ public class ItemBackpack extends ItemWithGui implements ActivatableFromInventor
@Override
protected void openGui(EntityPlayer entityplayer) {
GuiHandler.openGui(entityplayer, this, (short) type.ordinal());
GuiHandler.openGui(entityplayer, this, (short) type.ordinal(), entityplayer.inventory.currentItem);
}
@Override
@@ -34,7 +34,7 @@ public class ItemBackpackNaturalist extends ItemBackpack {
@Override
protected void openGui(EntityPlayer entityplayer) {
GuiHandler.openGui(entityplayer, this);
GuiHandler.openGui(entityplayer, this, (short) 0, entityplayer.inventory.currentItem);
}
@Override