Update libzontreck, update recipes, add directional flag to machines
This commit is contained in:
parent
f5ba08ab2d
commit
1ff8c7d398
15 changed files with 152 additions and 32 deletions
|
@ -9,25 +9,31 @@ import net.minecraft.server.level.ServerPlayer;
|
|||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BaseEntityBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CompressionChamberBlock extends BaseEntityBlock
|
||||
public class CompressionChamberBlock extends HorizontalDirectionalBlock implements EntityBlock
|
||||
{
|
||||
|
||||
public CompressionChamberBlock(Properties pProperties) {
|
||||
super(pProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
|
||||
super.createBlockStateDefinition(pBuilder);
|
||||
pBuilder.add(FACING);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||
|
@ -80,4 +86,15 @@ public class CompressionChamberBlock extends BaseEntityBlock
|
|||
|
||||
return createTickerHelper(pBlockEntityType, ModEntities.COMPRESSION_CHAMBER.get(), CompressionChamberBlockEntity::tick);
|
||||
}
|
||||
|
||||
|
||||
protected static <E extends BlockEntity, A extends BlockEntity> BlockEntityTicker<A> createTickerHelper(BlockEntityType<A> pServerType, BlockEntityType<E> pClientType, BlockEntityTicker<? super E> pTicker) {
|
||||
return pClientType == pServerType ? (BlockEntityTicker<A>) pTicker : null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
|
||||
return defaultBlockState().setValue(FACING, pContext.getHorizontalDirection());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,29 +5,37 @@ import dev.zontreck.otemod.blocks.entity.ModEntities;
|
|||
import dev.zontreck.otemod.networking.ModMessages;
|
||||
import dev.zontreck.otemod.networking.packets.EnergySyncS2CPacket;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BaseEntityBlock;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemScrubberBlock extends BaseEntityBlock
|
||||
public class ItemScrubberBlock extends HorizontalDirectionalBlock implements EntityBlock
|
||||
{
|
||||
|
||||
public ItemScrubberBlock(Properties p_54120_) {
|
||||
super(p_54120_);
|
||||
//registerDefaultState(defaultBlockState().setValue(FACING, Direction.NORTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
|
||||
super.createBlockStateDefinition(pBuilder);
|
||||
pBuilder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState state)
|
||||
|
@ -82,5 +90,13 @@ public class ItemScrubberBlock extends BaseEntityBlock
|
|||
{
|
||||
return createTickerHelper(type, ModEntities.ITEM_SCRUBBER.get(), ItemScrubberBlockEntity::tick);
|
||||
}
|
||||
|
||||
|
||||
protected static <E extends BlockEntity, A extends BlockEntity> BlockEntityTicker<A> createTickerHelper(BlockEntityType<A> pServerType, BlockEntityType<E> pClientType, BlockEntityTicker<? super E> pTicker) {
|
||||
return pClientType == pServerType ? (BlockEntityTicker<A>) pTicker : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
|
||||
return defaultBlockState().setValue(FACING, pContext.getHorizontalDirection().getOpposite());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,25 +9,31 @@ import net.minecraft.server.level.ServerPlayer;
|
|||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BaseEntityBlock;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class MagicalScrubberBlock extends BaseEntityBlock
|
||||
public class MagicalScrubberBlock extends HorizontalDirectionalBlock implements EntityBlock
|
||||
{
|
||||
|
||||
public MagicalScrubberBlock(Properties p_54120_) {
|
||||
super(p_54120_);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
|
||||
super.createBlockStateDefinition(pBuilder);
|
||||
pBuilder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState state)
|
||||
|
@ -81,5 +87,16 @@ public class MagicalScrubberBlock extends BaseEntityBlock
|
|||
{
|
||||
return createTickerHelper(type, ModEntities.MAGICAL_SCRUBBER.get(), MagicalScrubberBlockEntity::tick);
|
||||
}
|
||||
|
||||
|
||||
protected static <E extends BlockEntity, A extends BlockEntity> BlockEntityTicker<A> createTickerHelper(BlockEntityType<A> pServerType, BlockEntityType<E> pClientType, BlockEntityTicker<? super E> pTicker) {
|
||||
return pClientType == pServerType ? (BlockEntityTicker<A>) pTicker : null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
|
||||
return defaultBlockState().setValue(FACING, pContext.getHorizontalDirection().getOpposite());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class CompressionChamberBlockEntity extends BlockEntity implements MenuPr
|
|||
protected final ContainerData data;
|
||||
protected int progress=0;
|
||||
|
||||
public static final int MAXIMUM_PROCESSING_TICKS = 750;
|
||||
public static int PROCESSING_TICKS = 80;
|
||||
|
||||
protected final ItemStackHandler itemsHandler = new ItemStackHandler(1){
|
||||
@Override
|
||||
|
@ -99,7 +99,7 @@ public class CompressionChamberBlockEntity extends BlockEntity implements MenuPr
|
|||
};
|
||||
|
||||
|
||||
private static final int ENERGY_REQUIREMENT = 7500;
|
||||
private static int ENERGY_REQUIREMENT = 750;
|
||||
|
||||
private LazyOptional<IEnergyStorage> lazyEnergyHandler = LazyOptional.empty();
|
||||
|
||||
|
@ -207,7 +207,7 @@ public class CompressionChamberBlockEntity extends BlockEntity implements MenuPr
|
|||
setChanged(lvl, pos, state);
|
||||
drain(entity);
|
||||
|
||||
if(entity.progress >= CompressionChamberBlockEntity.MAXIMUM_PROCESSING_TICKS)
|
||||
if(entity.progress >= CompressionChamberBlockEntity.PROCESSING_TICKS)
|
||||
{
|
||||
craftItem(entity);
|
||||
}
|
||||
|
@ -275,7 +275,14 @@ public class CompressionChamberBlockEntity extends BlockEntity implements MenuPr
|
|||
|
||||
Optional<CompressionChamberRecipe> recipe = entity.level.getRecipeManager().getRecipeFor(CompressionChamberRecipe.Type.INSTANCE, inventory, entity.level);
|
||||
|
||||
return recipe.isPresent() && canInsertIntoOutput(output, recipe.get().getResultItem(entity.level.registryAccess()));
|
||||
boolean ret = recipe.isPresent() && canInsertIntoOutput(output, recipe.get().getResultItem(entity.level.registryAccess()));
|
||||
|
||||
if(ret)
|
||||
{
|
||||
PROCESSING_TICKS = recipe.get().getTime();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static boolean canInsertIntoOutput(SimpleContainer inventory, ItemStack result) {
|
||||
|
|
|
@ -60,7 +60,7 @@ public class ItemScrubberBlockEntity extends BlockEntity implements MenuProvider
|
|||
|
||||
};
|
||||
|
||||
private static final int ENERGY_REQ = 15000;
|
||||
private static final int ENERGY_REQ = 1500;
|
||||
private LazyOptional<IEnergyStorage> lazyEnergyHandler = LazyOptional.empty();
|
||||
|
||||
private LazyOptional<IItemHandler> lazyItemHandler = LazyOptional.empty();
|
||||
|
@ -100,7 +100,7 @@ public class ItemScrubberBlockEntity extends BlockEntity implements MenuProvider
|
|||
protected final ContainerData data;
|
||||
private int progress = 0;
|
||||
|
||||
public static final int MAXIMUM_PROCESSING_TICKS = 750;
|
||||
public static final int MAXIMUM_PROCESSING_TICKS = 250;
|
||||
|
||||
|
||||
@Override
|
||||
|
|
|
@ -66,7 +66,7 @@ public class MagicalScrubberBlockEntity extends BlockEntity implements MenuProvi
|
|||
|
||||
};
|
||||
|
||||
private static final int ENERGY_REQ = 10000;
|
||||
private static final int ENERGY_REQ = 1000;
|
||||
private LazyOptional<IEnergyStorage> lazyEnergyHandler = LazyOptional.empty();
|
||||
|
||||
private LazyOptional<IItemHandler> lazyItemHandler = LazyOptional.empty();
|
||||
|
@ -106,7 +106,7 @@ public class MagicalScrubberBlockEntity extends BlockEntity implements MenuProvi
|
|||
protected final ContainerData data;
|
||||
private int progress = 0;
|
||||
|
||||
public static final int MAXIMUM_PROCESSING_TICKS = 1750;
|
||||
public static final int MAXIMUM_PROCESSING_TICKS = 175;
|
||||
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,12 +16,14 @@ public class CompressionChamberRecipe implements Recipe<SimpleContainer> {
|
|||
private final ResourceLocation id;
|
||||
private final ItemStack output;
|
||||
private final Ingredient input;
|
||||
private final int seconds;
|
||||
|
||||
public CompressionChamberRecipe(ResourceLocation id, ItemStack output, Ingredient input)
|
||||
public CompressionChamberRecipe(ResourceLocation id, ItemStack output, Ingredient input, int seconds)
|
||||
{
|
||||
this.id=id;
|
||||
this.output=output;
|
||||
this.input=input;
|
||||
this.seconds=seconds;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,6 +63,10 @@ public class CompressionChamberRecipe implements Recipe<SimpleContainer> {
|
|||
return Type.INSTANCE;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return seconds*20;
|
||||
}
|
||||
|
||||
public static class Type implements RecipeType<CompressionChamberRecipe> {
|
||||
private Type(){}
|
||||
|
||||
|
@ -79,7 +85,9 @@ public class CompressionChamberRecipe implements Recipe<SimpleContainer> {
|
|||
|
||||
Ingredient input = Ingredient.fromJson(GsonHelper.getAsJsonObject(jsonObject, "input"));
|
||||
|
||||
return new CompressionChamberRecipe(resourceLocation, output, input);
|
||||
int seconds = GsonHelper.getAsInt(jsonObject, "time");
|
||||
|
||||
return new CompressionChamberRecipe(resourceLocation, output, input, seconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -87,13 +95,16 @@ public class CompressionChamberRecipe implements Recipe<SimpleContainer> {
|
|||
ItemStack output = friendlyByteBuf.readItem();
|
||||
|
||||
Ingredient input = Ingredient.fromNetwork(friendlyByteBuf);
|
||||
return new CompressionChamberRecipe(resourceLocation, output, input);
|
||||
int seconds = friendlyByteBuf.readInt();
|
||||
|
||||
return new CompressionChamberRecipe(resourceLocation, output, input, seconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toNetwork(FriendlyByteBuf friendlyByteBuf, CompressionChamberRecipe compressionChamberRecipe) {
|
||||
friendlyByteBuf.writeItem(compressionChamberRecipe.output);
|
||||
compressionChamberRecipe.input.toNetwork(friendlyByteBuf);
|
||||
friendlyByteBuf.writeInt(compressionChamberRecipe.seconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue