mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-26 14:53:05 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c1b7927d6 | ||
|
|
bf3ac85d88 | ||
|
|
d09b663ba6 | ||
|
|
3beacb998d | ||
|
|
52e7f95534 | ||
|
|
cc4cc558b8 | ||
|
|
956aaca10c | ||
|
|
23f7c9c7d9 |
No files matched your search
@@ -2,4 +2,4 @@ mcversion=1.7.10
|
|||||||
forgeversion=10.13.3.1370-1.7.10
|
forgeversion=10.13.3.1370-1.7.10
|
||||||
version_major=4
|
version_major=4
|
||||||
version_minor=0
|
version_minor=0
|
||||||
version_patch=9
|
version_patch=11
|
||||||
@@ -18,6 +18,7 @@ import net.minecraft.block.BlockFence;
|
|||||||
import net.minecraft.block.BlockFenceGate;
|
import net.minecraft.block.BlockFenceGate;
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
import net.minecraft.block.ITileEntityProvider;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.client.particle.EffectRenderer;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
@@ -41,10 +42,12 @@ import forestry.api.core.Tabs;
|
|||||||
import forestry.arboriculture.IWoodTyped;
|
import forestry.arboriculture.IWoodTyped;
|
||||||
import forestry.arboriculture.render.IconProviderWood;
|
import forestry.arboriculture.render.IconProviderWood;
|
||||||
import forestry.arboriculture.tiles.TileWood;
|
import forestry.arboriculture.tiles.TileWood;
|
||||||
|
import forestry.core.render.ParticleHelper;
|
||||||
import forestry.plugins.PluginArboriculture;
|
import forestry.plugins.PluginArboriculture;
|
||||||
|
|
||||||
public class BlockArbFence extends BlockFence implements IWoodTyped, ITileEntityProvider {
|
public class BlockArbFence extends BlockFence implements IWoodTyped, ITileEntityProvider {
|
||||||
|
|
||||||
|
private final ParticleHelper.Callback particleCallback;
|
||||||
private final boolean fireproof;
|
private final boolean fireproof;
|
||||||
|
|
||||||
public BlockArbFence(boolean fireproof) {
|
public BlockArbFence(boolean fireproof) {
|
||||||
@@ -57,6 +60,8 @@ public class BlockArbFence extends BlockFence implements IWoodTyped, ITileEntity
|
|||||||
setHarvestLevel("axe", 0);
|
setHarvestLevel("axe", 0);
|
||||||
setStepSound(soundTypeWood);
|
setStepSound(soundTypeWood);
|
||||||
setCreativeTab(Tabs.tabArboriculture);
|
setCreativeTab(Tabs.tabArboriculture);
|
||||||
|
|
||||||
|
this.particleCallback = new ParticleHelper.DefaultCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
@@ -174,4 +179,17 @@ public class BlockArbFence extends BlockFence implements IWoodTyped, ITileEntity
|
|||||||
public boolean isFireproof() {
|
public boolean isFireproof() {
|
||||||
return fireproof;
|
return fireproof;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Particles */
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
|
||||||
|
return ParticleHelper.addHitEffects(worldObj, this, target, effectRenderer, particleCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
|
||||||
|
return ParticleHelper.addDestroyEffects(worldObj, this, x, y, z, meta, effectRenderer, particleCallback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,7 @@ import java.util.List;
|
|||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockStairs;
|
import net.minecraft.block.BlockStairs;
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
import net.minecraft.block.ITileEntityProvider;
|
||||||
|
import net.minecraft.client.particle.EffectRenderer;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
@@ -37,9 +38,11 @@ import forestry.api.core.Tabs;
|
|||||||
import forestry.arboriculture.IWoodTyped;
|
import forestry.arboriculture.IWoodTyped;
|
||||||
import forestry.arboriculture.render.IconProviderWood;
|
import forestry.arboriculture.render.IconProviderWood;
|
||||||
import forestry.arboriculture.tiles.TileWood;
|
import forestry.arboriculture.tiles.TileWood;
|
||||||
|
import forestry.core.render.ParticleHelper;
|
||||||
|
|
||||||
public class BlockArbStairs extends BlockStairs implements IWoodTyped, ITileEntityProvider {
|
public class BlockArbStairs extends BlockStairs implements IWoodTyped, ITileEntityProvider {
|
||||||
|
|
||||||
|
private final ParticleHelper.Callback particleCallback;
|
||||||
private final boolean fireproof;
|
private final boolean fireproof;
|
||||||
|
|
||||||
public BlockArbStairs(Block par2Block, boolean fireproof) {
|
public BlockArbStairs(Block par2Block, boolean fireproof) {
|
||||||
@@ -51,6 +54,8 @@ public class BlockArbStairs extends BlockStairs implements IWoodTyped, ITileEnti
|
|||||||
setHardness(2.0F);
|
setHardness(2.0F);
|
||||||
setResistance(5.0F);
|
setResistance(5.0F);
|
||||||
setHarvestLevel("axe", 0);
|
setHarvestLevel("axe", 0);
|
||||||
|
|
||||||
|
this.particleCallback = new ParticleHelper.DefaultCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
@@ -126,4 +131,17 @@ public class BlockArbStairs extends BlockStairs implements IWoodTyped, ITileEnti
|
|||||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
||||||
return new TileWood();
|
return new TileWood();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Particles */
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
|
||||||
|
return ParticleHelper.addHitEffects(worldObj, this, target, effectRenderer, particleCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
|
||||||
|
return ParticleHelper.addDestroyEffects(worldObj, this, x, y, z, meta, effectRenderer, particleCallback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,7 @@ import java.util.Random;
|
|||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
import net.minecraft.block.ITileEntityProvider;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.client.particle.EffectRenderer;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
@@ -41,9 +42,11 @@ import forestry.api.core.Tabs;
|
|||||||
import forestry.arboriculture.IWoodTyped;
|
import forestry.arboriculture.IWoodTyped;
|
||||||
import forestry.arboriculture.render.IconProviderWood;
|
import forestry.arboriculture.render.IconProviderWood;
|
||||||
import forestry.arboriculture.tiles.TileWood;
|
import forestry.arboriculture.tiles.TileWood;
|
||||||
|
import forestry.core.render.ParticleHelper;
|
||||||
|
|
||||||
public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyped, ITileEntityProvider {
|
public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyped, ITileEntityProvider {
|
||||||
|
|
||||||
|
private final ParticleHelper.Callback particleCallback;
|
||||||
private final boolean fireproof;
|
private final boolean fireproof;
|
||||||
|
|
||||||
public BlockSlab(boolean fireproof) {
|
public BlockSlab(boolean fireproof) {
|
||||||
@@ -57,6 +60,8 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
|
|||||||
setResistance(5.0F);
|
setResistance(5.0F);
|
||||||
setStepSound(soundTypeWood);
|
setStepSound(soundTypeWood);
|
||||||
setHarvestLevel("axe", 0);
|
setHarvestLevel("axe", 0);
|
||||||
|
|
||||||
|
this.particleCallback = new ParticleHelper.DefaultCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -183,4 +188,17 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
|
|||||||
public Item getItem(World world, int x, int y, int z) {
|
public Item getItem(World world, int x, int y, int z) {
|
||||||
return Item.getItemFromBlock(this);
|
return Item.getItemFromBlock(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Particles */
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
|
||||||
|
return ParticleHelper.addHitEffects(worldObj, this, target, effectRenderer, particleCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
|
||||||
|
return ParticleHelper.addDestroyEffects(worldObj, this, x, y, z, meta, effectRenderer, particleCallback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@ import java.util.ArrayList;
|
|||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
import net.minecraft.block.ITileEntityProvider;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.client.particle.EffectRenderer;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -35,10 +36,12 @@ import forestry.api.core.Tabs;
|
|||||||
import forestry.arboriculture.IWoodTyped;
|
import forestry.arboriculture.IWoodTyped;
|
||||||
import forestry.arboriculture.render.IconProviderWood;
|
import forestry.arboriculture.render.IconProviderWood;
|
||||||
import forestry.arboriculture.tiles.TileWood;
|
import forestry.arboriculture.tiles.TileWood;
|
||||||
|
import forestry.core.render.ParticleHelper;
|
||||||
import forestry.core.tiles.TileUtil;
|
import forestry.core.tiles.TileUtil;
|
||||||
|
|
||||||
public abstract class BlockWood extends Block implements ITileEntityProvider, IWoodTyped {
|
public abstract class BlockWood extends Block implements ITileEntityProvider, IWoodTyped {
|
||||||
|
|
||||||
|
private final ParticleHelper.Callback particleCallback;
|
||||||
private final String blockKind;
|
private final String blockKind;
|
||||||
private final boolean fireproof;
|
private final boolean fireproof;
|
||||||
|
|
||||||
@@ -49,6 +52,8 @@ public abstract class BlockWood extends Block implements ITileEntityProvider, IW
|
|||||||
|
|
||||||
setStepSound(soundTypeWood);
|
setStepSound(soundTypeWood);
|
||||||
setCreativeTab(Tabs.tabArboriculture);
|
setCreativeTab(Tabs.tabArboriculture);
|
||||||
|
|
||||||
|
particleCallback = new ParticleHelper.DefaultCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -138,4 +143,16 @@ public abstract class BlockWood extends Block implements ITileEntityProvider, IW
|
|||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public abstract IIcon getIcon(IBlockAccess world, int x, int y, int z, int side);
|
public abstract IIcon getIcon(IBlockAccess world, int x, int y, int z, int side);
|
||||||
|
|
||||||
|
/* Particles */
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
|
||||||
|
return ParticleHelper.addHitEffects(worldObj, this, target, effectRenderer, particleCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
|
||||||
|
return ParticleHelper.addDestroyEffects(worldObj, this, x, y, z, meta, effectRenderer, particleCallback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -48,10 +48,12 @@ import forestry.api.genetics.IChromosome;
|
|||||||
import forestry.api.genetics.IEffectData;
|
import forestry.api.genetics.IEffectData;
|
||||||
import forestry.api.genetics.IFruitFamily;
|
import forestry.api.genetics.IFruitFamily;
|
||||||
import forestry.api.genetics.IMutation;
|
import forestry.api.genetics.IMutation;
|
||||||
|
import forestry.arboriculture.tiles.TileLeaves;
|
||||||
import forestry.core.config.Config;
|
import forestry.core.config.Config;
|
||||||
import forestry.core.genetics.Chromosome;
|
import forestry.core.genetics.Chromosome;
|
||||||
import forestry.core.genetics.Individual;
|
import forestry.core.genetics.Individual;
|
||||||
import forestry.core.genetics.alleles.Allele;
|
import forestry.core.genetics.alleles.Allele;
|
||||||
|
import forestry.core.tiles.TileUtil;
|
||||||
import forestry.core.utils.StringUtil;
|
import forestry.core.utils.StringUtil;
|
||||||
|
|
||||||
public class Tree extends Individual implements ITree, IPlantable {
|
public class Tree extends Individual implements ITree, IPlantable {
|
||||||
@@ -222,6 +224,10 @@ public class Tree extends Individual implements ITree, IPlantable {
|
|||||||
@Override
|
@Override
|
||||||
public void setLeaves(World world, GameProfile owner, int x, int y, int z) {
|
public void setLeaves(World world, GameProfile owner, int x, int y, int z) {
|
||||||
genome.getPrimary().getGenerator().setLeaves(world, owner, x, y, z, false);
|
genome.getPrimary().getGenerator().setLeaves(world, owner, x, y, z, false);
|
||||||
|
TileLeaves leaves = TileUtil.getTile(world, x, y, z, TileLeaves.class);
|
||||||
|
if (leaves != null) {
|
||||||
|
leaves.setTree(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -49,35 +49,20 @@ public class ParticleHelper {
|
|||||||
|
|
||||||
if (sideHit == 0) {
|
if (sideHit == 0) {
|
||||||
py = (double) y + block.getBlockBoundsMinY() - (double) b;
|
py = (double) y + block.getBlockBoundsMinY() - (double) b;
|
||||||
}
|
} else if (sideHit == 1) {
|
||||||
|
|
||||||
if (sideHit == 1) {
|
|
||||||
py = (double) y + block.getBlockBoundsMaxY() + (double) b;
|
py = (double) y + block.getBlockBoundsMaxY() + (double) b;
|
||||||
}
|
} else if (sideHit == 2) {
|
||||||
|
|
||||||
if (sideHit == 2) {
|
|
||||||
pz = (double) z + block.getBlockBoundsMinZ() - (double) b;
|
pz = (double) z + block.getBlockBoundsMinZ() - (double) b;
|
||||||
}
|
} else if (sideHit == 3) {
|
||||||
|
|
||||||
if (sideHit == 3) {
|
|
||||||
pz = (double) z + block.getBlockBoundsMaxZ() + (double) b;
|
pz = (double) z + block.getBlockBoundsMaxZ() + (double) b;
|
||||||
}
|
} else if (sideHit == 4) {
|
||||||
|
|
||||||
if (sideHit == 4) {
|
|
||||||
px = (double) x + block.getBlockBoundsMinX() - (double) b;
|
px = (double) x + block.getBlockBoundsMinX() - (double) b;
|
||||||
}
|
} else if (sideHit == 5) {
|
||||||
|
|
||||||
if (sideHit == 5) {
|
|
||||||
px = (double) x + block.getBlockBoundsMaxX() + (double) b;
|
px = (double) x + block.getBlockBoundsMaxX() + (double) b;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityDiggingFX fx = new EntityDiggingFX(world, px, py, pz, 0.0D, 0.0D, 0.0D, block, sideHit, meta);
|
EntityDiggingFX fx = new EntityDiggingFX(world, px, py, pz, 0.0D, 0.0D, 0.0D, block, sideHit, meta);
|
||||||
fx.setParticleIcon(block.getIcon(world, x, y, z, 0));
|
callback.addHitEffects(fx, world, x, y, z, meta, sideHit);
|
||||||
|
|
||||||
if (callback != null) {
|
|
||||||
callback.addHitEffects(fx, world, x, y, z, meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
|
effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -90,7 +75,6 @@ public class ParticleHelper {
|
|||||||
* the location is this block.
|
* the location is this block.
|
||||||
*
|
*
|
||||||
* @param world The current world
|
* @param world The current world
|
||||||
* @param block
|
|
||||||
* @param x X position to spawn the particle
|
* @param x X position to spawn the particle
|
||||||
* @param y Y position to spawn the particle
|
* @param y Y position to spawn the particle
|
||||||
* @param z Z position to spawn the particle
|
* @param z Z position to spawn the particle
|
||||||
@@ -115,12 +99,7 @@ public class ParticleHelper {
|
|||||||
int random = rand.nextInt(6);
|
int random = rand.nextInt(6);
|
||||||
|
|
||||||
EntityDiggingFX fx = new EntityDiggingFX(world, px, py, pz, px - x - 0.5D, py - y - 0.5D, pz - z - 0.5D, block, random, meta);
|
EntityDiggingFX fx = new EntityDiggingFX(world, px, py, pz, px - x - 0.5D, py - y - 0.5D, pz - z - 0.5D, block, random, meta);
|
||||||
fx.setParticleIcon(block.getIcon(world, x, y, z, 0));
|
callback.addDestroyEffects(fx, world, x, y, z, meta);
|
||||||
|
|
||||||
if (callback != null) {
|
|
||||||
callback.addDestroyEffects(fx, world, x, y, z, meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z));
|
effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,9 +111,35 @@ public class ParticleHelper {
|
|||||||
public interface Callback {
|
public interface Callback {
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
void addHitEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta);
|
void addHitEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta, int side);
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
void addDestroyEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta);
|
void addDestroyEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class DefaultCallback implements ParticleHelper.Callback {
|
||||||
|
|
||||||
|
private final Block block;
|
||||||
|
|
||||||
|
public DefaultCallback(Block block) {
|
||||||
|
this.block = block;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void addHitEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta, int side) {
|
||||||
|
setTexture(fx, world, x, y, z, side);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void addDestroyEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta) {
|
||||||
|
setTexture(fx, world, x, y, z, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
private void setTexture(EntityDiggingFX fx, World world, int x, int y, int z, int side) {
|
||||||
|
fx.setParticleIcon(block.getIcon(world, x, y, z, side));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -104,11 +104,7 @@ public abstract class SlotUtil {
|
|||||||
return shiftToHotbar(inventorySlots, stackInSlot);
|
return shiftToHotbar(inventorySlots, stackInSlot);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
boolean shifted = shiftToHotbar(inventorySlots, stackInSlot);
|
return shiftToPlayerInventory(inventorySlots, stackInSlot);
|
||||||
if (!shifted) {
|
|
||||||
shifted = shiftToPlayerInventoryNoHotbar(inventorySlots, stackInSlot);
|
|
||||||
}
|
|
||||||
return shifted;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,38 +154,31 @@ public abstract class SlotUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean shiftItemStackToRange(List inventorySlots, ItemStack stackToShift, int start, int count) {
|
private static boolean shiftItemStackToRange(List inventorySlots, ItemStack stackToShift, int start, int count) {
|
||||||
boolean changed = false;
|
boolean changed = shiftItemStackToRangeMerge(inventorySlots, stackToShift, start, count);
|
||||||
if (stackToShift.isStackable()) {
|
changed |= shiftItemStackToRangeOpenSlots(inventorySlots, stackToShift, start, count);
|
||||||
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < start + count; slotIndex++) {
|
return changed;
|
||||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
}
|
||||||
ItemStack stackInSlot = slot.getStack();
|
|
||||||
if (stackInSlot != null && ItemStackUtil.isIdenticalItem(stackInSlot, stackToShift)) {
|
private static boolean shiftItemStackToRangeMerge(List inventorySlots, ItemStack stackToShift, int start, int count) {
|
||||||
int resultingStackSize = stackInSlot.stackSize + stackToShift.stackSize;
|
if (stackToShift == null || !stackToShift.isStackable() || stackToShift.stackSize <= 0) {
|
||||||
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
|
return false;
|
||||||
if (resultingStackSize <= max) {
|
|
||||||
stackToShift.stackSize = 0;
|
|
||||||
stackInSlot.stackSize = resultingStackSize;
|
|
||||||
slot.onSlotChanged();
|
|
||||||
changed = true;
|
|
||||||
} else if (stackInSlot.stackSize < max) {
|
|
||||||
stackToShift.stackSize -= max - stackInSlot.stackSize;
|
|
||||||
stackInSlot.stackSize = max;
|
|
||||||
slot.onSlotChanged();
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (stackToShift.stackSize > 0) {
|
|
||||||
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < start + count; slotIndex++) {
|
boolean changed = false;
|
||||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < start + count; slotIndex++) {
|
||||||
ItemStack stackInSlot = slot.getStack();
|
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||||
if (stackInSlot == null) {
|
ItemStack stackInSlot = slot.getStack();
|
||||||
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
|
if (stackInSlot != null && ItemStackUtil.isIdenticalItem(stackInSlot, stackToShift)) {
|
||||||
stackInSlot = stackToShift.copy();
|
int resultingStackSize = stackInSlot.stackSize + stackToShift.stackSize;
|
||||||
stackInSlot.stackSize = Math.min(stackToShift.stackSize, max);
|
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
|
||||||
stackToShift.stackSize -= stackInSlot.stackSize;
|
if (resultingStackSize <= max) {
|
||||||
slot.putStack(stackInSlot);
|
stackToShift.stackSize = 0;
|
||||||
|
stackInSlot.stackSize = resultingStackSize;
|
||||||
|
slot.onSlotChanged();
|
||||||
|
changed = true;
|
||||||
|
} else if (stackInSlot.stackSize < max) {
|
||||||
|
stackToShift.stackSize -= max - stackInSlot.stackSize;
|
||||||
|
stackInSlot.stackSize = max;
|
||||||
slot.onSlotChanged();
|
slot.onSlotChanged();
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
@@ -198,6 +187,28 @@ public abstract class SlotUtil {
|
|||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean shiftItemStackToRangeOpenSlots(List inventorySlots, ItemStack stackToShift, int start, int count) {
|
||||||
|
if (stackToShift == null || stackToShift.stackSize <= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean changed = false;
|
||||||
|
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < start + count; slotIndex++) {
|
||||||
|
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||||
|
ItemStack stackInSlot = slot.getStack();
|
||||||
|
if (stackInSlot == null) {
|
||||||
|
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
|
||||||
|
stackInSlot = stackToShift.copy();
|
||||||
|
stackInSlot.stackSize = Math.min(stackToShift.stackSize, max);
|
||||||
|
stackToShift.stackSize -= stackInSlot.stackSize;
|
||||||
|
slot.putStack(stackInSlot);
|
||||||
|
slot.onSlotChanged();
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
private static final int playerInventorySize = 9 * 4;
|
private static final int playerInventorySize = 9 * 4;
|
||||||
private static final int playerHotbarSize = 9;
|
private static final int playerHotbarSize = 9;
|
||||||
|
|
||||||
@@ -209,6 +220,19 @@ public abstract class SlotUtil {
|
|||||||
return SlotUtil.isSlotInRange(slotIndex, playerInventorySize - playerHotbarSize, playerInventorySize);
|
return SlotUtil.isSlotInRange(slotIndex, playerInventorySize - playerHotbarSize, playerInventorySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean shiftToPlayerInventory(List inventorySlots, ItemStack stackInSlot) {
|
||||||
|
int playerHotbarStart = playerInventorySize - playerHotbarSize;
|
||||||
|
|
||||||
|
// try to merge with existing stacks, hotbar first
|
||||||
|
boolean shifted = shiftItemStackToRangeMerge(inventorySlots, stackInSlot, playerHotbarStart, playerHotbarSize);
|
||||||
|
shifted |= shiftItemStackToRangeMerge(inventorySlots, stackInSlot, 0, playerHotbarStart);
|
||||||
|
|
||||||
|
// shift to open slots, hotbar first
|
||||||
|
shifted |= shiftItemStackToRangeOpenSlots(inventorySlots, stackInSlot, playerHotbarStart, playerHotbarSize);
|
||||||
|
shifted |= shiftItemStackToRangeOpenSlots(inventorySlots, stackInSlot, 0, playerHotbarStart);
|
||||||
|
return shifted;
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean shiftToPlayerInventoryNoHotbar(List inventorySlots, ItemStack stackInSlot) {
|
private static boolean shiftToPlayerInventoryNoHotbar(List inventorySlots, ItemStack stackInSlot) {
|
||||||
int playerHotbarStart = playerInventorySize - playerHotbarSize;
|
int playerHotbarStart = playerInventorySize - playerHotbarSize;
|
||||||
return shiftItemStackToRange(inventorySlots, stackInSlot, 0, playerHotbarStart);
|
return shiftItemStackToRange(inventorySlots, stackInSlot, 0, playerHotbarStart);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import forestry.core.network.GuiId;
|
|||||||
import forestry.core.recipes.RecipeUtil;
|
import forestry.core.recipes.RecipeUtil;
|
||||||
import forestry.core.tiles.TileBase;
|
import forestry.core.tiles.TileBase;
|
||||||
import forestry.core.utils.InventoryUtil;
|
import forestry.core.utils.InventoryUtil;
|
||||||
|
import forestry.core.utils.ItemStackUtil;
|
||||||
import forestry.core.utils.SlotUtil;
|
import forestry.core.utils.SlotUtil;
|
||||||
import forestry.factory.recipes.RecipeMemory;
|
import forestry.factory.recipes.RecipeMemory;
|
||||||
|
|
||||||
@@ -194,11 +195,20 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!itemStack.getItem().hasContainerItem(itemStack)) {
|
ItemStack container = null;
|
||||||
continue;
|
|
||||||
|
if (itemStack.getItem().hasContainerItem(itemStack)) {
|
||||||
|
container = itemStack.getItem().getContainerItem(itemStack);
|
||||||
|
} else if (itemStack.stackSize > 1) {
|
||||||
|
// TerraFirmaCraft's crafting event handler does some tricky stuff with its tools.
|
||||||
|
// It sets the tool's stack size to 2 instead of using a container.
|
||||||
|
container = ItemStackUtil.createSplitStack(itemStack, itemStack.stackSize - 1);
|
||||||
|
itemStack.stackSize = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack container = itemStack.getItem().getContainerItem(itemStack);
|
if (container == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (container != null && container.isItemStackDamageable() && container.getItemDamage() > container.getMaxDamage()) {
|
if (container != null && container.isItemStackDamageable() && container.getItemDamage() > container.getMaxDamage()) {
|
||||||
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, container));
|
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, container));
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import java.util.List;
|
|||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.particle.EffectRenderer;
|
import net.minecraft.client.particle.EffectRenderer;
|
||||||
import net.minecraft.client.particle.EntityDiggingFX;
|
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
@@ -47,12 +46,12 @@ import forestry.plugins.PluginFarming;
|
|||||||
|
|
||||||
public class BlockFarm extends BlockStructure {
|
public class BlockFarm extends BlockStructure {
|
||||||
|
|
||||||
private static BlockFarm instance;
|
private final ParticleHelper.Callback particleCallback;
|
||||||
|
|
||||||
public BlockFarm() {
|
public BlockFarm() {
|
||||||
super(Material.rock);
|
super(Material.rock);
|
||||||
setHardness(1.0f);
|
setHardness(1.0f);
|
||||||
instance = this;
|
this.particleCallback = new ParticleHelper.DefaultCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -162,40 +161,6 @@ public class BlockFarm extends BlockStructure {
|
|||||||
EnumFarmBlockTexture.registerIcons(register);
|
EnumFarmBlockTexture.registerIcons(register);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ParticleCallback implements ParticleHelper.Callback {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void addHitEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta) {
|
|
||||||
setTexture(fx, world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void addDestroyEffects(EntityDiggingFX fx, World world, int x, int y, int z, int meta) {
|
|
||||||
setTexture(fx, world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private static void setTexture(EntityDiggingFX fx, World world, int x, int y, int z) {
|
|
||||||
fx.setParticleIcon(instance.getIcon(world, x, y, z, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final ParticleHelper.Callback callback = new ParticleCallback();
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
|
||||||
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
|
|
||||||
return ParticleHelper.addHitEffects(worldObj, instance, target, effectRenderer, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
|
||||||
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
|
|
||||||
return ParticleHelper.addDestroyEffects(worldObj, instance, x, y, z, meta, effectRenderer, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public IIcon getIcon(int side, int metadata) {
|
public IIcon getIcon(int side, int metadata) {
|
||||||
@@ -237,11 +202,6 @@ public class BlockFarm extends BlockStructure {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) {
|
|
||||||
return world.getBlockMetadata(x, y, z) == 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||||
@@ -260,4 +220,22 @@ public class BlockFarm extends BlockStructure {
|
|||||||
return block.getIcon(side, base.getItemDamage());
|
return block.getIcon(side, base.getItemDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Particles */
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
|
||||||
|
return ParticleHelper.addHitEffects(worldObj, this, target, effectRenderer, particleCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
|
||||||
|
return ParticleHelper.addDestroyEffects(worldObj, this, x, y, z, meta, effectRenderer, particleCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) {
|
||||||
|
return world.getBlockMetadata(x, y, z) == 5;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package forestry.food.items;
|
package forestry.food.items;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -71,7 +72,7 @@ public class ItemBeverage extends ItemForestryFood {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<IBeverageEffect> loadEffects(ItemStack stack) {
|
public static List<IBeverageEffect> loadEffects(ItemStack stack) {
|
||||||
List<IBeverageEffect> effectsList = Collections.emptyList();
|
List<IBeverageEffect> effectsList = new ArrayList<>();
|
||||||
|
|
||||||
NBTTagCompound nbttagcompound = stack.getTagCompound();
|
NBTTagCompound nbttagcompound = stack.getTagCompound();
|
||||||
if (nbttagcompound == null) {
|
if (nbttagcompound == null) {
|
||||||
|
|||||||
@@ -140,8 +140,10 @@ public class PluginMagicalCrops extends ForestryPlugin {
|
|||||||
|
|
||||||
ImmutableList<String> betaSeeds = ImmutableList.of(
|
ImmutableList<String> betaSeeds = ImmutableList.of(
|
||||||
"Air",
|
"Air",
|
||||||
|
"Airshard",
|
||||||
"Aluminium",
|
"Aluminium",
|
||||||
"Alumite",
|
"Alumite",
|
||||||
|
"Amber",
|
||||||
"Ardite",
|
"Ardite",
|
||||||
"Blaze",
|
"Blaze",
|
||||||
"Blizz",
|
"Blizz",
|
||||||
@@ -150,18 +152,25 @@ public class PluginMagicalCrops extends ForestryPlugin {
|
|||||||
"Chicken",
|
"Chicken",
|
||||||
"Coal",
|
"Coal",
|
||||||
"Cobalt",
|
"Cobalt",
|
||||||
|
"ConductiveIron",
|
||||||
"Copper",
|
"Copper",
|
||||||
"Cow",
|
"Cow",
|
||||||
"Creeper",
|
"Creeper",
|
||||||
|
"DarkSteel",
|
||||||
"Diamond",
|
"Diamond",
|
||||||
|
"Draconium",
|
||||||
"Dye",
|
"Dye",
|
||||||
"Earth",
|
"Earth",
|
||||||
|
"Earthshard",
|
||||||
|
"ElectricalSteel",
|
||||||
"Electrum",
|
"Electrum",
|
||||||
"Emerald",
|
"Emerald",
|
||||||
"Enderium",
|
"Enderium",
|
||||||
"Enderman",
|
"Enderman",
|
||||||
|
"EnergeticAlloy",
|
||||||
"Experience",
|
"Experience",
|
||||||
"Fire",
|
"Fire",
|
||||||
|
"Fireshard",
|
||||||
"Fluix",
|
"Fluix",
|
||||||
"Ghast",
|
"Ghast",
|
||||||
"Glowstone",
|
"Glowstone",
|
||||||
@@ -178,11 +187,15 @@ public class PluginMagicalCrops extends ForestryPlugin {
|
|||||||
"Nether",
|
"Nether",
|
||||||
"Nickel",
|
"Nickel",
|
||||||
"Obsidian",
|
"Obsidian",
|
||||||
|
"Ordershard",
|
||||||
"Osmium",
|
"Osmium",
|
||||||
"Peridot",
|
"Peridot",
|
||||||
"Pig",
|
"Pig",
|
||||||
"Platinum",
|
"Platinum",
|
||||||
|
"PulsatingIron",
|
||||||
"Quartz",
|
"Quartz",
|
||||||
|
"Quicksilver",
|
||||||
|
"RedstoneAlloy",
|
||||||
"Redstone",
|
"Redstone",
|
||||||
"Rubber",
|
"Rubber",
|
||||||
"Ruby",
|
"Ruby",
|
||||||
@@ -193,12 +206,16 @@ public class PluginMagicalCrops extends ForestryPlugin {
|
|||||||
"Silver",
|
"Silver",
|
||||||
"Skeleton",
|
"Skeleton",
|
||||||
"Slime",
|
"Slime",
|
||||||
|
"Soularium",
|
||||||
"Spider",
|
"Spider",
|
||||||
"Steel",
|
"Steel",
|
||||||
"Sulfur",
|
"Sulfur",
|
||||||
"Terrasteel",
|
"Terrasteel",
|
||||||
|
"Thaumium",
|
||||||
"Tin",
|
"Tin",
|
||||||
|
"VibrantAlloy",
|
||||||
"Water",
|
"Water",
|
||||||
|
"Watershard",
|
||||||
"Wither",
|
"Wither",
|
||||||
"Yellorite"
|
"Yellorite"
|
||||||
);
|
);
|
||||||
@@ -229,7 +246,8 @@ public class PluginMagicalCrops extends ForestryPlugin {
|
|||||||
addRecipes("_Seeds", "_Crop", seedName, seedAmount);
|
addRecipes("_Seeds", "_Crop", seedName, seedAmount);
|
||||||
}
|
}
|
||||||
for (String seedName : betaSeeds) {
|
for (String seedName : betaSeeds) {
|
||||||
addBetaRecipes("Seeds", "Crop", seedName);
|
addBetaRecipes("Seeds", "Crop", seedName, "");
|
||||||
|
addBetaRecipes("Seeds", "Crop", seedName, "magicalcrops_");
|
||||||
}
|
}
|
||||||
|
|
||||||
Item cropProduce = GameRegistry.findItem(MagCrop, MagCrop + "_CropProduce");
|
Item cropProduce = GameRegistry.findItem(MagCrop, MagCrop + "_CropProduce");
|
||||||
@@ -252,9 +270,9 @@ public class PluginMagicalCrops extends ForestryPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addBetaRecipes(String seedSuffix, String cropSuffix, String name) {
|
private static void addBetaRecipes(String seedSuffix, String cropSuffix, String name, String middlefix) {
|
||||||
ItemStack seed = GameRegistry.findItemStack(MagCrop, MagCrop + "_" + name + seedSuffix, 1);
|
ItemStack seed = GameRegistry.findItemStack(MagCrop, middlefix + name + seedSuffix, 1);
|
||||||
Block crop = GameRegistry.findBlock(MagCrop, MagCrop + "_" + name + cropSuffix);
|
Block crop = GameRegistry.findBlock(MagCrop, middlefix + name + cropSuffix);
|
||||||
if (seed != null && crop != null && Config.isMagicalCropsSupportEnabled()) {
|
if (seed != null && crop != null && Config.isMagicalCropsSupportEnabled()) {
|
||||||
Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(seed, crop, 7));
|
Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(seed, crop, 7));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user