mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-25 20:58:34 +01:00
added the hopper enhancement
This commit is contained in:
parent
ca9e8456ae
commit
1b0df8272f
10 changed files with 150 additions and 3 deletions
|
@ -0,0 +1,10 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityHopperUpgrade;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
public class BlockHopperUpgrade extends BlockContainerImpl {
|
||||
public BlockHopperUpgrade() {
|
||||
super(Material.IRON, "hopper_upgrade", TileEntityHopperUpgrade.class, "hopper_upgrade");
|
||||
}
|
||||
}
|
|
@ -30,4 +30,5 @@ public final class ModBlocks {
|
|||
public static final Block CONVERSION_CATALYST = new BlockImpl("conversion_catalyst", Material.ROCK).setSoundType(SoundType.STONE).setHardness(2.5F);
|
||||
public static final Block FLOWER_GENERATOR = new BlockFlowerGenerator();
|
||||
public static final Block PLACER = new BlockPlacer();
|
||||
public static final Block HOPPER_UPGRADE = new BlockHopperUpgrade();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
import de.ellpeck.naturesaura.aura.chunk.AuraChunk;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
import net.minecraft.block.BlockHopper;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityHopper;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityHopperUpgrade extends TileEntityImpl implements ITickable {
|
||||
@Override
|
||||
public void update() {
|
||||
if (!this.world.isRemote && this.world.getTotalWorldTime() % 10 == 0) {
|
||||
if (AuraChunk.getAuraInArea(this.world, this.pos, 25) < 1000)
|
||||
return;
|
||||
TileEntity tile = this.world.getTileEntity(this.pos.down());
|
||||
if (!(tile instanceof TileEntityHopper) || !BlockHopper.isEnabled(tile.getBlockMetadata()))
|
||||
return;
|
||||
TileEntityHopper hopper = (TileEntityHopper) tile;
|
||||
if (!hopper.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP))
|
||||
return;
|
||||
IItemHandler handler = hopper.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);
|
||||
if (handler == null)
|
||||
return;
|
||||
|
||||
List<EntityItem> items = this.world.getEntitiesWithinAABB(EntityItem.class,
|
||||
new AxisAlignedBB(this.pos).grow(7));
|
||||
if (items.isEmpty())
|
||||
return;
|
||||
|
||||
for (EntityItem item : items) {
|
||||
if (item.isDead || item.cannotPickup())
|
||||
continue;
|
||||
ItemStack stack = item.getItem();
|
||||
if (stack.isEmpty())
|
||||
continue;
|
||||
ItemStack copy = stack.copy();
|
||||
|
||||
for (int i = 0; i < handler.getSlots(); i++) {
|
||||
copy = handler.insertItem(i, copy, false);
|
||||
if (copy.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ItemStack.areItemStacksEqual(stack, copy)) {
|
||||
item.setItem(copy);
|
||||
if (copy.isEmpty())
|
||||
item.setDead();
|
||||
|
||||
BlockPos spot = AuraChunk.getHighestSpot(this.world, this.pos, 25, this.pos);
|
||||
AuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 10);
|
||||
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 10));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -188,6 +188,14 @@ public class PacketParticles implements IMessage {
|
|||
0xad7a37, world.rand.nextFloat() + 1F, 50, 0F, true, true);
|
||||
}
|
||||
break;
|
||||
case 10: // Hopper upgrade picking up
|
||||
for (int i = world.rand.nextInt(20) + 10; i >= 0; i--)
|
||||
NaturesAura.proxy.spawnMagicParticle(world,
|
||||
message.posX, message.posY + 0.45F, message.posZ,
|
||||
world.rand.nextGaussian() * 0.015F,
|
||||
world.rand.nextGaussian() * 0.015F,
|
||||
world.rand.nextGaussian() * 0.015F,
|
||||
0xdde7ff, world.rand.nextFloat() + 1F, 30, -0.06F, true, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -29,9 +29,9 @@ public class ParticleMagic extends Particle {
|
|||
this.motionY = motionY;
|
||||
this.motionZ = motionZ;
|
||||
|
||||
float r = (((color >> 16) & 255) / 255F) * (1F - this.rand.nextFloat() * 0.35F);
|
||||
float g = (((color >> 8) & 255) / 255F) * (1F - this.rand.nextFloat() * 0.35F);
|
||||
float b = ((color & 255) / 255F) * (1F - this.rand.nextFloat() * 0.35F);
|
||||
float r = (((color >> 16) & 255) / 255F) * (1F - this.rand.nextFloat() * 0.25F);
|
||||
float g = (((color >> 8) & 255) / 255F) * (1F - this.rand.nextFloat() * 0.25F);
|
||||
float b = ((color & 255) / 255F) * (1F - this.rand.nextFloat() * 0.25F);
|
||||
this.setRBGColorF(r, g, b);
|
||||
|
||||
TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks();
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"forge_marker": 1,
|
||||
"defaults": {
|
||||
"model": "minecraft:cube_all",
|
||||
"textures": {
|
||||
"all": "naturesaura:blocks/hopper_upgrade"
|
||||
},
|
||||
"transform": "forge:default-block"
|
||||
},
|
||||
"variants": {
|
||||
"normal": [{}],
|
||||
"inventory": [{}]
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ tile.naturesaura.infused_brick_slab.name=Infused Brick Slab
|
|||
tile.naturesaura.infused_brick_slab_double.name=Infused Brick Double Slab
|
||||
tile.naturesaura.flower_generator.name=Herbivorous Absorber
|
||||
tile.naturesaura.placer.name=Imperceptible Builder
|
||||
tile.naturesaura.hopper_upgrade.name=Hopper Enhancement
|
||||
|
||||
item.naturesaura.eye.name=Environmental Eye
|
||||
item.naturesaura.gold_fiber.name=Brilliant Fiber
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "Hopper Enhancement",
|
||||
"icon": "naturesaura:hopper_upgrade",
|
||||
"category": "using",
|
||||
"advancement": "naturesaura:infused_materials",
|
||||
"pages": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": "Collecting items using $(item)Hoppers$() is useful, but sometimes, it can be inconvenient, especially if given a big area that one has to collect items in. For that, the $(item)Hopper Enhancement$() will be a help: By simply placing it on top of any $(item)Hopper$(), it will increase its range of picking up items drastically by about $(thing)seven$() blocks.$(br)When collecting an item, it then uses a small amount of $(aura)."
|
||||
},
|
||||
{
|
||||
"type": "crafting",
|
||||
"text": "Creating the $(item)Hopper Enhancement$()",
|
||||
"recipe": "naturesaura:hopper_upgrade"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"type": "forge:ore_shaped",
|
||||
"pattern": [
|
||||
"RIR",
|
||||
"IEI",
|
||||
"RHR"
|
||||
],
|
||||
"key": {
|
||||
"H": {
|
||||
"item": "minecraft:hopper"
|
||||
},
|
||||
"I": {
|
||||
"item": "naturesaura:infused_iron"
|
||||
},
|
||||
"R": {
|
||||
"type": "forge:ore_dict",
|
||||
"ore": "ingotIron"
|
||||
},
|
||||
"E": {
|
||||
"item": "minecraft:ender_pearl"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "naturesaura:hopper_upgrade"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 739 B |
Loading…
Reference in a new issue