mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 05:08:34 +01:00
added the powder manipulator
This commit is contained in:
parent
e78472570a
commit
f15ad75c2e
15 changed files with 238 additions and 9 deletions
|
@ -26,6 +26,7 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class BlockContainerImpl extends BlockContainer implements IModItem, ICreativeItem, IModelProvider {
|
public class BlockContainerImpl extends BlockContainer implements IModItem, ICreativeItem, IModelProvider {
|
||||||
|
|
||||||
|
@ -132,10 +133,22 @@ public class BlockContainerImpl extends BlockContainer implements IModItem, ICre
|
||||||
TileEntityImpl impl = (TileEntityImpl) tile;
|
TileEntityImpl impl = (TileEntityImpl) tile;
|
||||||
int newPower = world.getRedstonePowerFromNeighbors(pos);
|
int newPower = world.getRedstonePowerFromNeighbors(pos);
|
||||||
if (impl.redstonePower != newPower) {
|
if (impl.redstonePower != newPower) {
|
||||||
|
boolean pulse = impl.redstonePower <= 0 && newPower > 0;
|
||||||
impl.redstonePower = newPower;
|
impl.redstonePower = newPower;
|
||||||
impl.onRedstonePowerChange();
|
impl.onRedstonePowerChange();
|
||||||
|
if (pulse)
|
||||||
|
world.scheduleUpdate(pos, this, this.tickRate(world));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
|
||||||
|
if (!worldIn.isRemote) {
|
||||||
|
TileEntity tile = worldIn.getTileEntity(pos);
|
||||||
|
if (tile instanceof TileEntityImpl)
|
||||||
|
((TileEntityImpl) tile).onRedstonePulse();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package de.ellpeck.naturesaura.blocks;
|
||||||
|
|
||||||
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPowderPlacer;
|
||||||
|
import net.minecraft.block.SoundType;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.BlockFaceShape;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
|
||||||
|
public class BlockPowderPlacer extends BlockContainerImpl {
|
||||||
|
private static final AxisAlignedBB BOUND_BOX = new AxisAlignedBB(0F, 0F, 0F, 1F, 4 / 16F, 1F);
|
||||||
|
|
||||||
|
public BlockPowderPlacer() {
|
||||||
|
super(Material.ROCK, "powder_placer", TileEntityPowderPlacer.class, "powder_placer");
|
||||||
|
this.setSoundType(SoundType.STONE);
|
||||||
|
this.setHardness(2.5F);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
|
||||||
|
return BOUND_BOX;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFullCube(IBlockState state) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOpaqueCube(IBlockState state) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSideSolid(IBlockState baseState, IBlockAccess world, BlockPos pos, EnumFacing side) {
|
||||||
|
return side == EnumFacing.DOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
|
||||||
|
return BlockFaceShape.UNDEFINED;
|
||||||
|
}
|
||||||
|
}
|
|
@ -114,7 +114,6 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable
|
||||||
int radius = ((TileEntitySpawnLamp) tile).getRadius();
|
int radius = ((TileEntitySpawnLamp) tile).getRadius();
|
||||||
if (radius > 0)
|
if (radius > 0)
|
||||||
return new AxisAlignedBB(pos).grow(radius);
|
return new AxisAlignedBB(pos).grow(radius);
|
||||||
System.out.println(radius);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,4 +50,5 @@ public final class ModBlocks {
|
||||||
public static final Block TIME_CHANGER = new BlockTimeChanger();
|
public static final Block TIME_CHANGER = new BlockTimeChanger();
|
||||||
public static final Block GENERATOR_LIMIT_REMOVER = new BlockImpl("generator_limit_remover", Material.ROCK).setSoundType(SoundType.STONE).setHardness(2F);
|
public static final Block GENERATOR_LIMIT_REMOVER = new BlockImpl("generator_limit_remover", Material.ROCK).setSoundType(SoundType.STONE).setHardness(2F);
|
||||||
public static final Block ENDER_CRATE = new BlockEnderCrate();
|
public static final Block ENDER_CRATE = new BlockEnderCrate();
|
||||||
|
public static final Block POWDER_PLACER = new BlockPowderPlacer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,10 @@ public class TileEntityImpl extends TileEntity {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onRedstonePulse(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final SPacketUpdateTileEntity getUpdatePacket() {
|
public final SPacketUpdateTileEntity getUpdatePacket() {
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
|
import de.ellpeck.naturesaura.entities.EntityEffectInhibitor;
|
||||||
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.EntitySelectors;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TileEntityPowderPlacer extends TileEntityImpl {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRedstonePulse() {
|
||||||
|
List<EntityEffectInhibitor> powders = this.world.getEntitiesWithinAABB(EntityEffectInhibitor.class,
|
||||||
|
new AxisAlignedBB(this.pos, this.pos.add(1, 2, 1)), EntitySelectors.IS_ALIVE);
|
||||||
|
for (EnumFacing facing : EnumFacing.HORIZONTALS) {
|
||||||
|
TileEntity tile = this.world.getTileEntity(this.pos.offset(facing));
|
||||||
|
if (tile == null || !tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()))
|
||||||
|
continue;
|
||||||
|
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite());
|
||||||
|
if (handler == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!powders.isEmpty()) {
|
||||||
|
for (EntityEffectInhibitor powder : powders) {
|
||||||
|
ItemStack drop = powder.getDrop();
|
||||||
|
for (int i = 0; i < handler.getSlots(); i++) {
|
||||||
|
ItemStack remain = handler.insertItem(i, drop, false);
|
||||||
|
if (remain.isEmpty()) {
|
||||||
|
powder.setDead();
|
||||||
|
break;
|
||||||
|
} else if (remain.getCount() != drop.getCount()) {
|
||||||
|
powder.setAmount(remain.getCount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < handler.getSlots(); i++) {
|
||||||
|
ItemStack stack = handler.extractItem(i, Integer.MAX_VALUE, true);
|
||||||
|
if (stack.isEmpty() || stack.getItem() != ModItems.EFFECT_POWDER)
|
||||||
|
continue;
|
||||||
|
EntityEffectInhibitor.place(this.world, stack, this.pos.getX() + 0.5, this.pos.getY() + 1, this.pos.getZ() + 0.5);
|
||||||
|
handler.extractItem(i, Integer.MAX_VALUE, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.entities;
|
||||||
import com.google.common.collect.ListMultimap;
|
import com.google.common.collect.ListMultimap;
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.misc.IWorldData;
|
import de.ellpeck.naturesaura.api.misc.IWorldData;
|
||||||
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||||
import de.ellpeck.naturesaura.items.ItemEffectPowder;
|
import de.ellpeck.naturesaura.items.ItemEffectPowder;
|
||||||
|
@ -40,6 +41,16 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
|
||||||
super(worldIn);
|
super(worldIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void place(World world, ItemStack stack, double posX, double posY, double posZ) {
|
||||||
|
ResourceLocation effect = ItemEffectPowder.getEffect(stack);
|
||||||
|
EntityEffectInhibitor entity = new EntityEffectInhibitor(world);
|
||||||
|
entity.setInhibitedEffect(effect);
|
||||||
|
entity.setColor(NaturesAuraAPI.EFFECT_POWDERS.get(effect));
|
||||||
|
entity.setAmount(stack.getCount());
|
||||||
|
entity.setPosition(posX, posY, posZ);
|
||||||
|
world.spawnEntity(entity);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAddedToWorld() {
|
public void onAddedToWorld() {
|
||||||
super.onAddedToWorld();
|
super.onAddedToWorld();
|
||||||
|
@ -134,12 +145,16 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
|
||||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||||
if (source instanceof EntityDamageSource && !this.world.isRemote) {
|
if (source instanceof EntityDamageSource && !this.world.isRemote) {
|
||||||
this.setDead();
|
this.setDead();
|
||||||
this.entityDropItem(ItemEffectPowder.setEffect(new ItemStack(ModItems.EFFECT_POWDER, this.getAmount()), this.getInhibitedEffect()), 0F);
|
this.entityDropItem(this.getDrop(), 0F);
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
return super.attackEntityFrom(source, amount);
|
return super.attackEntityFrom(source, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemStack getDrop() {
|
||||||
|
return ItemEffectPowder.setEffect(new ItemStack(ModItems.EFFECT_POWDER, this.getAmount()), this.getInhibitedEffect());
|
||||||
|
}
|
||||||
|
|
||||||
public void setInhibitedEffect(ResourceLocation effect) {
|
public void setInhibitedEffect(ResourceLocation effect) {
|
||||||
this.removeFromPowderList();
|
this.removeFromPowderList();
|
||||||
this.dataManager.set(INHIBITED_EFFECT, effect.toString());
|
this.dataManager.set(INHIBITED_EFFECT, effect.toString());
|
||||||
|
|
|
@ -25,13 +25,7 @@ public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem {
|
||||||
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||||
if (!worldIn.isRemote) {
|
if (!worldIn.isRemote) {
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
ResourceLocation effect = getEffect(stack);
|
EntityEffectInhibitor.place(worldIn, stack, pos.getX() + hitX, pos.getY() + hitY + 1, pos.getZ() + hitZ);
|
||||||
EntityEffectInhibitor entity = new EntityEffectInhibitor(worldIn);
|
|
||||||
entity.setInhibitedEffect(effect);
|
|
||||||
entity.setColor(NaturesAuraAPI.EFFECT_POWDERS.get(effect));
|
|
||||||
entity.setAmount(stack.getCount());
|
|
||||||
entity.setPosition(pos.getX() + hitX, pos.getY() + hitY + 1, pos.getZ() + hitZ);
|
|
||||||
worldIn.spawnEntity(entity);
|
|
||||||
stack.setCount(0);
|
stack.setCount(0);
|
||||||
}
|
}
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"forge_marker": 1,
|
||||||
|
"defaults": {
|
||||||
|
"model": "naturesaura:powder_placer",
|
||||||
|
"textures": {
|
||||||
|
"texture": "naturesaura:blocks/powder_placer",
|
||||||
|
"top": "naturesaura:blocks/powder_placer_top",
|
||||||
|
"particle": "#top"
|
||||||
|
},
|
||||||
|
"transform": "forge:default-block"
|
||||||
|
},
|
||||||
|
"variants": {
|
||||||
|
"normal": [{}],
|
||||||
|
"inventory": [{}]
|
||||||
|
}
|
||||||
|
}
|
|
@ -46,6 +46,7 @@ tile.naturesaura.moss_generator.name=Swamp Homi
|
||||||
tile.naturesaura.time_changer.name=Shifting Sundial
|
tile.naturesaura.time_changer.name=Shifting Sundial
|
||||||
tile.naturesaura.generator_limit_remover.name=Creational Catalyst
|
tile.naturesaura.generator_limit_remover.name=Creational Catalyst
|
||||||
tile.naturesaura.ender_crate.name=Ender Crate
|
tile.naturesaura.ender_crate.name=Ender Crate
|
||||||
|
tile.naturesaura.powder_placer.name=Powder Manipulator
|
||||||
|
|
||||||
item.naturesaura.eye.name=Environmental Eye
|
item.naturesaura.eye.name=Environmental Eye
|
||||||
item.naturesaura.eye_improved.name=Environmental Ocular
|
item.naturesaura.eye_improved.name=Environmental Ocular
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
{
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"from": [0, 0, 0],
|
||||||
|
"to": [16, 4, 16],
|
||||||
|
"faces": {
|
||||||
|
"down": {
|
||||||
|
"uv": [0, 0, 16, 16],
|
||||||
|
"texture": "#top",
|
||||||
|
"cullface": "down"
|
||||||
|
},
|
||||||
|
"up": {
|
||||||
|
"uv": [0, 0, 16, 16],
|
||||||
|
"texture": "#top"
|
||||||
|
},
|
||||||
|
"north": {
|
||||||
|
"uv": [0, 12, 16, 16],
|
||||||
|
"texture": "#texture",
|
||||||
|
"cullface": "north"
|
||||||
|
},
|
||||||
|
"south": {
|
||||||
|
"uv": [0, 12, 16, 16],
|
||||||
|
"texture": "#texture",
|
||||||
|
"cullface": "south"
|
||||||
|
},
|
||||||
|
"west": {
|
||||||
|
"uv": [0, 12, 16, 16],
|
||||||
|
"texture": "#texture",
|
||||||
|
"cullface": "west"
|
||||||
|
},
|
||||||
|
"east": {
|
||||||
|
"uv": [0, 12, 16, 16],
|
||||||
|
"texture": "#texture",
|
||||||
|
"cullface": "east"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"name": "Powder Manipulator",
|
||||||
|
"icon": "naturesaura:powder_placer",
|
||||||
|
"category": "devices",
|
||||||
|
"advancement": "naturesaura:positive_imbalance",
|
||||||
|
"pages": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"text": "Using $(l:effects/effect_powder)Effect Powder$() can prove to be quite useful when trying to inhibit or start certain $(thing)Aura Imbalance$() effects. The $(item)Powder Manipulator$() helps with this greatly: Placing a chest on any side of it and placing any kind of $(item)Effect Powder$() into it will cause it to, upon receiving a $(thing)redstone pulse$(), place that powder down in the world."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "crafting",
|
||||||
|
"text": "Similarly, upon giving it another pulse, it will collect the powder that it has placed on top of it once again and deposit it in a nearby chest.",
|
||||||
|
"recipe": "naturesaura:powder_placer"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
"type": "forge:ore_shaped",
|
||||||
|
"pattern": [
|
||||||
|
" A ",
|
||||||
|
"PSP",
|
||||||
|
" T "
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"P": {
|
||||||
|
"item": "naturesaura:gold_powder"
|
||||||
|
},
|
||||||
|
"S": {
|
||||||
|
"item": "naturesaura:infused_stone"
|
||||||
|
},
|
||||||
|
"T": {
|
||||||
|
"item": "naturesaura:token_joy"
|
||||||
|
},
|
||||||
|
"A": {
|
||||||
|
"item": "naturesaura:token_anger"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"item": "naturesaura:powder_placer"
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 363 B |
Binary file not shown.
After Width: | Height: | Size: 671 B |
Loading…
Reference in a new issue