mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-10 20:11:35 +01:00
composting, but fancy
- add the composter as a mechanical arm interaction point
This commit is contained in:
parent
f6b9d71169
commit
46daa3f699
1 changed files with 57 additions and 49 deletions
|
@ -1,9 +1,5 @@
|
|||
package com.simibubi.create.content.logistics.block.mechanicalArm;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
@ -25,10 +21,10 @@ import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBe
|
|||
import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipulationBehaviour;
|
||||
import com.simibubi.create.foundation.utility.NBTHelper;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.ComposterBlock;
|
||||
import net.minecraft.block.JukeboxBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.MusicDiscItem;
|
||||
|
@ -50,10 +46,14 @@ import net.minecraftforge.common.util.LazyOptional;
|
|||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class ArmInteractionPoint {
|
||||
|
||||
static enum Mode {
|
||||
enum Mode {
|
||||
DEPOSIT, TAKE
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,7 @@ public abstract class ArmInteractionPoint {
|
|||
.put(new Jukebox(), Jukebox::new)
|
||||
.put(new Crafter(), Crafter::new)
|
||||
.put(new Deployer(), Deployer::new)
|
||||
.put(new Composter(), Composter::new)
|
||||
.put(new Millstone(), Millstone::new)
|
||||
.put(new BlazeBurner(), BlazeBurner::new)
|
||||
.put(new CrushingWheels(), CrushingWheels::new)
|
||||
|
@ -118,8 +119,8 @@ public abstract class ArmInteractionPoint {
|
|||
|
||||
ArmAngleTarget getTargetAngles(BlockPos armPos, boolean ceiling) {
|
||||
if (cachedAngles == null)
|
||||
cachedAngles =
|
||||
new ArmAngleTarget(armPos, getInteractionPositionVector(), getInteractionDirection(), ceiling);
|
||||
cachedAngles = new ArmAngleTarget(armPos, getInteractionPositionVector(), getInteractionDirection(), ceiling);
|
||||
|
||||
return cachedAngles;
|
||||
}
|
||||
|
||||
|
@ -166,8 +167,7 @@ public abstract class ArmInteractionPoint {
|
|||
|
||||
for (ArmInteractionPoint armInteractionPoint : POINTS.keySet())
|
||||
if (armInteractionPoint.isValid(world, pos, state))
|
||||
point = POINTS.get(armInteractionPoint)
|
||||
.get();
|
||||
point = POINTS.get(armInteractionPoint).get();
|
||||
|
||||
if (point != null) {
|
||||
point.state = state;
|
||||
|
@ -245,6 +245,25 @@ public abstract class ArmInteractionPoint {
|
|||
|
||||
}
|
||||
|
||||
static class Composter extends TopFaceArmInteractionPoint {
|
||||
|
||||
@Override
|
||||
Vec3d getInteractionPositionVector() {
|
||||
return new Vec3d(pos).add(.5f, 13 / 16f, .5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) {
|
||||
return Blocks.COMPOSTER.equals(state.getBlock());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
IItemHandler getHandler(World world) {
|
||||
return new InvWrapper(((ComposterBlock) Blocks.COMPOSTER).createInventory(world.getBlockState(pos), world, pos));
|
||||
}
|
||||
}
|
||||
|
||||
static class Deployer extends ArmInteractionPoint {
|
||||
|
||||
@Override
|
||||
|
@ -254,14 +273,12 @@ public abstract class ArmInteractionPoint {
|
|||
|
||||
@Override
|
||||
Direction getInteractionDirection() {
|
||||
return state.get(DeployerBlock.FACING)
|
||||
.getOpposite();
|
||||
return state.get(DeployerBlock.FACING).getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
Vec3d getInteractionPositionVector() {
|
||||
return super.getInteractionPositionVector()
|
||||
.add(new Vec3d(getInteractionDirection().getDirectionVec()).scale(.65f));
|
||||
return super.getInteractionPositionVector().add(new Vec3d(getInteractionDirection().getDirectionVec()).scale(.65f));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -281,9 +298,7 @@ public abstract class ArmInteractionPoint {
|
|||
@Override
|
||||
ItemStack insert(World world, ItemStack stack, boolean simulate) {
|
||||
ItemStack input = stack.copy();
|
||||
if (!BlazeBurnerBlock.tryInsert(state, world, pos, input, false, true)
|
||||
.getResult()
|
||||
.isEmpty()) {
|
||||
if (!BlazeBurnerBlock.tryInsert(state, world, pos, input, false, true).getResult().isEmpty()) {
|
||||
return stack;
|
||||
}
|
||||
ActionResult<ItemStack> res = BlazeBurnerBlock.tryInsert(state, world, pos, input, false, simulate);
|
||||
|
@ -306,8 +321,7 @@ public abstract class ArmInteractionPoint {
|
|||
|
||||
@Override
|
||||
Direction getInteractionDirection() {
|
||||
return state.get(MechanicalCrafterBlock.HORIZONTAL_FACING)
|
||||
.getOpposite();
|
||||
return state.get(MechanicalCrafterBlock.HORIZONTAL_FACING).getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -325,8 +339,7 @@ public abstract class ArmInteractionPoint {
|
|||
|
||||
@Override
|
||||
Vec3d getInteractionPositionVector() {
|
||||
return super.getInteractionPositionVector()
|
||||
.add(new Vec3d(getInteractionDirection().getDirectionVec()).scale(.5f));
|
||||
return super.getInteractionPositionVector().add(new Vec3d(getInteractionDirection().getDirectionVec()).scale(.5f));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -361,8 +374,7 @@ public abstract class ArmInteractionPoint {
|
|||
return stack;
|
||||
JukeboxBlock jukeboxBlock = (JukeboxBlock) state.getBlock();
|
||||
JukeboxTileEntity jukeboxTE = (JukeboxTileEntity) tileEntity;
|
||||
if (!jukeboxTE.getRecord()
|
||||
.isEmpty())
|
||||
if (!jukeboxTE.getRecord().isEmpty())
|
||||
return stack;
|
||||
if (!(stack.getItem() instanceof MusicDiscItem))
|
||||
return stack;
|
||||
|
@ -370,7 +382,7 @@ public abstract class ArmInteractionPoint {
|
|||
ItemStack toInsert = remainder.split(1);
|
||||
if (!simulate && !world.isRemote) {
|
||||
jukeboxBlock.insertRecord(world, pos, state, toInsert);
|
||||
world.playEvent((PlayerEntity) null, 1010, pos, Item.getIdFromItem(toInsert.getItem()));
|
||||
world.playEvent(null, 1010, pos, Item.getIdFromItem(toInsert.getItem()));
|
||||
AllTriggers.triggerForNearbyPlayers(AllTriggers.MUSICAL_ARM, world, pos, 10);
|
||||
}
|
||||
return remainder;
|
||||
|
@ -401,8 +413,7 @@ public abstract class ArmInteractionPoint {
|
|||
|
||||
@Override
|
||||
boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) {
|
||||
return AllBlocks.BELT.has(state) && !(reader.getBlockState(pos.up())
|
||||
.getBlock() instanceof BeltTunnelBlock);
|
||||
return AllBlocks.BELT.has(state) && !(reader.getBlockState(pos.up()).getBlock() instanceof BeltTunnelBlock);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -418,9 +429,7 @@ public abstract class ArmInteractionPoint {
|
|||
|
||||
@Override
|
||||
Vec3d getInteractionPositionVector() {
|
||||
return VecHelper.getCenterOf(pos)
|
||||
.add(new Vec3d(FunnelBlock.getFunnelFacing(state)
|
||||
.getDirectionVec()).scale(-.15f));
|
||||
return VecHelper.getCenterOf(pos).add(new Vec3d(FunnelBlock.getFunnelFacing(state).getDirectionVec()).scale(-.15f));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -435,8 +444,7 @@ public abstract class ArmInteractionPoint {
|
|||
|
||||
@Override
|
||||
Direction getInteractionDirection() {
|
||||
return FunnelBlock.getFunnelFacing(state)
|
||||
.getOpposite();
|
||||
return FunnelBlock.getFunnelFacing(state).getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue