Derailed Capabilities

- more porting
- port JEI plugin
- use new capability lifecycle for minecarts
This commit is contained in:
simibubi 2021-11-02 23:17:26 +01:00
parent cb987307c0
commit d35f5905ff
60 changed files with 349 additions and 359 deletions

View file

@ -45,6 +45,7 @@ import net.minecraft.world.level.levelgen.placement.FeatureDecorator;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.ForgeMod;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent;
import net.minecraftforge.event.world.BiomeLoadingEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.IEventBus;
@ -128,7 +129,6 @@ public class Create {
}
public static void init(final FMLCommonSetupEvent event) {
CapabilityMinecartController.register();
AllPackets.registerPackets();
SchematicInstances.register();
BuiltinPotatoProjectileTypes.register();
@ -153,6 +153,10 @@ public class Create {
ProcessingRecipeGen.registerAll(gen);
}
public static void registerCapabilities(RegisterCapabilitiesEvent event) {
event.register(CapabilityMinecartController.class);
}
public static void onBiomeLoad(BiomeLoadingEvent event) {
AllWorldFeatures.reload(event);
}

View file

@ -10,7 +10,8 @@ import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.crafting.Recipe;
public class BlueprintTransferHandler implements IRecipeTransferHandler<BlueprintContainer> {
@SuppressWarnings("rawtypes")
public class BlueprintTransferHandler implements IRecipeTransferHandler<BlueprintContainer, Recipe> {
@Override
public Class<BlueprintContainer> getContainerClass() {
@ -18,8 +19,13 @@ public class BlueprintTransferHandler implements IRecipeTransferHandler<Blueprin
}
@Override
public IRecipeTransferError transferRecipe(BlueprintContainer container, Object recipe, IRecipeLayout recipeLayout,
Player player, boolean maxTransfer, boolean doTransfer) {
public Class<Recipe> getRecipeClass() {
return Recipe.class;
}
@Override
public IRecipeTransferError transferRecipe(BlueprintContainer container, Recipe recipe,
IRecipeLayout recipeLayout, Player player, boolean maxTransfer, boolean doTransfer) {
if (!(recipe instanceof Recipe))
return null;
if (!doTransfer)

View file

@ -2,7 +2,6 @@ package com.simibubi.create.compat.jei;
import java.util.function.Supplier;
import com.mojang.blaze3d.platform.Lighting;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.gui.GuiGameElement;
@ -39,8 +38,6 @@ public class DoubleItemIcon implements IDrawable {
secondaryStack = secondarySupplier.get();
}
Lighting.turnBackOn();
RenderSystem.color4f(1, 1, 1, 1);
RenderSystem.enableDepthTest();
matrixStack.pushPose();
matrixStack.translate(xOffset, yOffset, 0);

View file

@ -32,7 +32,7 @@ import net.minecraftforge.fluids.FluidStack;
public abstract class CreateRecipeCategory<T extends Recipe<?>> implements IRecipeCategory<T> {
public final List<Supplier<List<? extends Recipe<?>>>> recipes = new ArrayList<>();
public final List<Supplier<? extends Object>> recipeCatalysts = new ArrayList<>();
public final List<Supplier<? extends ItemStack>> recipeCatalysts = new ArrayList<>();
protected ResourceLocation uid;
protected String name;
@ -55,9 +55,8 @@ public abstract class CreateRecipeCategory<T extends Recipe<?>> implements IReci
}
@Override
public String getTitle() {
return Lang.translate("recipe." + name)
.getString();
public Component getTitle() {
return Lang.translate("recipe." + name);
}
@Override
@ -101,7 +100,8 @@ public abstract class CreateRecipeCategory<T extends Recipe<?>> implements IReci
addStochasticTooltip(itemStacks, results, 1);
}
public static void addStochasticTooltip(IGuiItemStackGroup itemStacks, List<ProcessingOutput> results, int startIndex) {
public static void addStochasticTooltip(IGuiItemStackGroup itemStacks, List<ProcessingOutput> results,
int startIndex) {
itemStacks.addTooltipCallback((slotIndex, input, ingredient, tooltip) -> {
if (input)
return;

View file

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.mojang.blaze3d.platform.Lighting;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlocks;
@ -50,8 +49,7 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory<CraftingRec
NonNullList<Ingredient> recipeIngredients = recipe.getIngredients();
itemStacks.init(0, false, 133, 80);
itemStacks.set(0, recipe.getResultItem()
.getStack());
itemStacks.set(0, recipe.getResultItem());
int x = getXPadding(recipe);
int y = getYPadding(recipe);
@ -122,7 +120,6 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory<CraftingRec
matrixStack.pushPose();
matrixStack.translate(0, 0, 300);
Lighting.turnOff();
int amount = 0;
for (Ingredient ingredient : recipe.getIngredients()) {
if (Ingredient.EMPTY == ingredient)
@ -155,18 +152,18 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory<CraftingRec
matrixStack.scale(scale, scale, scale);
if (ingredient != null) {
RenderSystem.pushMatrix();
RenderSystem.multMatrix(matrixStack.last().pose());
PoseStack modelViewStack = RenderSystem.getModelViewStack();
modelViewStack.pushPose();
modelViewStack.mulPoseMatrix(matrixStack.last()
.pose());
RenderSystem.enableDepthTest();
Lighting.turnBackOn();
Minecraft minecraft = Minecraft.getInstance();
Font font = getFontRenderer(minecraft, ingredient);
ItemRenderer itemRenderer = minecraft.getItemRenderer();
itemRenderer.renderAndDecorateItem(null, ingredient, 0, 0);
itemRenderer.renderGuiItemDecorations(font, ingredient, 0, 0, null);
itemRenderer.renderAndDecorateFakeItem(ingredient, xPosition, yPosition);
itemRenderer.renderGuiItemDecorations(font, ingredient, xPosition, yPosition, null);
RenderSystem.disableBlend();
Lighting.turnOff();
RenderSystem.popMatrix();
modelViewStack.popPose();
}
matrixStack.popPose();

View file

@ -8,7 +8,6 @@ import java.util.Map;
import java.util.stream.Collectors;
import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllItems;
import com.simibubi.create.compat.jei.EmptyBackground;
@ -145,9 +144,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory<SequencedAss
if (recipe.getLoops() > 1) {
matrixStack.pushPose();
matrixStack.translate(15, 9, 0);
RenderSystem.color4f(.65f, .65f, .65f, 1);
AllIcons.I_REFRESH.draw(matrixStack, 50 + xOffset, 75);
RenderSystem.color4f(1, 1, 1, 1);
AllIcons.I_SEQ_REPEAT.draw(matrixStack, 50 + xOffset, 75);
Component repeat = new TextComponent("x" + recipe.getLoops());
font.draw(matrixStack, repeat, 66 + xOffset, 80, 0x888888);
matrixStack.popPose();

View file

@ -37,8 +37,8 @@ public class SeatEntity extends Entity implements IEntityAdditionalSpawnData {
}
@Override
public void setPosRaw(double x, double y, double z) {
super.setPosRaw(x, y, z);
public void setPos(double x, double y, double z) {
super.setPos(x, y, z);
AABB bb = getBoundingBox();
Vec3 diff = new Vec3(x, y, z).subtract(bb.getCenter());
setBoundingBox(bb.move(diff));

View file

@ -31,8 +31,6 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.BucketPickup;
import net.minecraft.world.level.block.entity.BeehiveBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FlowingFluid;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.phys.Vec3;
public interface IMovedDispenseItemBehaviour {
@ -40,8 +38,7 @@ public interface IMovedDispenseItemBehaviour {
static void initSpawneggs() {
final IMovedDispenseItemBehaviour spawnEggDispenseBehaviour = new MovedDefaultDispenseItemBehaviour() {
@Override
protected ItemStack dispenseStack(ItemStack itemStack, MovementContext context, BlockPos pos,
Vec3 facing) {
protected ItemStack dispenseStack(ItemStack itemStack, MovementContext context, BlockPos pos, Vec3 facing) {
if (!(itemStack.getItem() instanceof SpawnEggItem))
return super.dispenseStack(itemStack, context, pos, facing);
if (context.world instanceof ServerLevel) {
@ -64,8 +61,7 @@ public interface IMovedDispenseItemBehaviour {
static void init() {
MovedProjectileDispenserBehaviour movedPotionDispenseItemBehaviour = new MovedProjectileDispenserBehaviour() {
@Override
protected Projectile getProjectileEntity(Level world, double x, double y, double z,
ItemStack itemStack) {
protected Projectile getProjectileEntity(Level world, double x, double y, double z, ItemStack itemStack) {
return Util.make(new ThrownPotion(world, x, y, z), (p_218411_1_) -> p_218411_1_.setItem(itemStack));
}
@ -162,14 +158,12 @@ public interface IMovedDispenseItemBehaviour {
((BeehiveBlock) block).releaseBeesAndResetHoneyLevel(context.world, state, interactAt, null,
BeehiveBlockEntity.BeeReleaseStatus.BEE_RELEASED);
this.successful = true;
return placeItemInInventory(itemStack, new ItemStack(Items.HONEY_BOTTLE), context, pos,
facing);
return placeItemInInventory(itemStack, new ItemStack(Items.HONEY_BOTTLE), context, pos, facing);
} else if (context.world.getFluidState(interactAt)
.is(FluidTags.WATER)) {
this.successful = true;
return placeItemInInventory(itemStack,
PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER), context, pos,
facing);
PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER), context, pos, facing);
} else {
return super.dispenseStack(itemStack, context, pos, facing);
}
@ -185,10 +179,8 @@ public interface IMovedDispenseItemBehaviour {
BlockState state = context.world.getBlockState(interactAt);
Block block = state.getBlock();
if (block instanceof BucketPickup) {
Fluid fluid = ((BucketPickup) block).takeLiquid(context.world, interactAt, state);
if (fluid instanceof FlowingFluid)
return placeItemInInventory(itemStack, new ItemStack(fluid.getBucket()), context, pos,
facing);
ItemStack bucket = ((BucketPickup) block).pickupBlock(context.world, interactAt, state);
return placeItemInInventory(itemStack, bucket, context, pos, facing);
}
return super.dispenseStack(itemStack, context, pos, facing);
}

View file

@ -141,7 +141,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
return;
IControlContraption controller = getController();
if (controller == null) {
remove();
discard();
return;
}
if (!controller.isAttachedTo(this)) {

View file

@ -66,7 +66,7 @@ public class MountedStorage {
te.getLevel()
.setBlockAndUpdate(te.getBlockPos(), te.getBlockState()
.setValue(ChestBlock.TYPE, ChestType.SINGLE));
te.clearCache();
// te.clearCache();
}
// Split double flexcrates
@ -76,7 +76,7 @@ public class MountedStorage {
te.getLevel()
.setBlockAndUpdate(te.getBlockPos(), te.getBlockState()
.setValue(AdjustableCrateBlock.DOUBLE, false));
te.clearCache();
// te.clearCache();
}
IItemHandler teHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)

View file

@ -7,6 +7,7 @@ import com.simibubi.create.foundation.networking.SimplePacketBase;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.fmllegacy.network.NetworkEvent.Context;
import net.minecraftforge.fmllegacy.network.PacketDistributor;
@ -49,7 +50,7 @@ public class ClientMotionPacket extends SimplePacketBase {
sender.setDeltaMovement(motion);
sender.setOnGround(onGround);
if (onGround) {
sender.causeFallDamage(sender.fallDistance, 1);
sender.causeFallDamage(sender.fallDistance, 1, DamageSource.FALL);
sender.fallDistance = 0;
sender.connection.aboveGroundTickCount = 0;
}

View file

@ -55,13 +55,11 @@ public class ContraptionInteractionPacket extends SimplePacketBase {
return;
AbstractContraptionEntity contraptionEntity = (AbstractContraptionEntity) entityByID;
double d = sender.getAttribute(ForgeMod.REACH_DISTANCE.get()).getValue() + 10;
if (!sender.canSee(entityByID))
if (!sender.hasLineOfSight(entityByID))
d -= 3;
d *= d;
if (sender.distanceToSqr(entityByID) > d) {
// TODO log?
if (sender.distanceToSqr(entityByID) > d)
return;
}
if (contraptionEntity.handlePlayerInteraction(sender, localPos, face, interactionHand))
sender.swing(interactionHand, true);
});

View file

@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.tr
import java.util.Random;
import com.mojang.math.Vector3f;
import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.VecHelper;
@ -56,7 +57,8 @@ public class CouplingHandlerClient {
ClientLevel world = Minecraft.getInstance().level;
Vec3 center = AABB.getCenter();
int amount = highlight ? 100 : 2;
ParticleOptions particleData = highlight ? ParticleTypes.END_ROD : new DustParticleOptions(1, 1, 1, 1);
ParticleOptions particleData =
highlight ? ParticleTypes.END_ROD : new DustParticleOptions(new Vector3f(1, 1, 1), 1);
for (int i = 0; i < amount; i++) {
Vec3 v = VecHelper.offsetRandomly(Vec3.ZERO, r, 1);
double yOffset = v.y;

View file

@ -99,8 +99,7 @@ public class CouplingPhysics {
motions.replaceWithParams(VecHelper::clamp, Couple.create(1f, 1f));
Couple<Vec3> nextPositions = carts.map(MinecartSim2020::predictNextPositionOf);
Couple<RailShape> shapes = carts.mapWithContext((cart, current) -> {
AbstractMinecart minecart = cart.getMinecart();
Couple<RailShape> shapes = carts.mapWithContext((minecart, current) -> {
Vec3 vec = nextPositions.get(current);
int x = Mth.floor(vec.x());
int y = Mth.floor(vec.y());
@ -112,7 +111,7 @@ public class CouplingPhysics {
if (!(railState.getBlock() instanceof BaseRailBlock))
return null;
BaseRailBlock block = (BaseRailBlock) railState.getBlock();
return block.getRailDirection(railState, world, railPosition, cart);
return block.getRailDirection(railState, world, railPosition, minecart);
});
float futureStress = (float) (couplingLength - nextPositions.getFirst()

View file

@ -71,8 +71,8 @@ public class MinecartCouplingItem extends Item {
return true;
}
private static boolean onWrenchInteractOnMinecart(EntityInteract event, AbstractMinecart minecart,
Player player, MinecartController controller) {
private static boolean onWrenchInteractOnMinecart(EntityInteract event, AbstractMinecart minecart, Player player,
MinecartController controller) {
int couplings = (controller.isConnectedToCoupling() ? 1 : 0) + (controller.isLeadingCoupling() ? 1 : 0);
if (couplings == 0)
return false;
@ -87,8 +87,8 @@ public class MinecartCouplingItem extends Item {
CouplingHandler.status(player, "removed");
controller.decouple();
if (!player.isCreative())
player.getInventory().placeItemBackInInventory(event.getWorld(),
new ItemStack(AllItems.MINECART_COUPLING.get(), couplings));
player.getInventory()
.placeItemBackInInventory(new ItemStack(AllItems.MINECART_COUPLING.get(), couplings));
return true;
}

View file

@ -21,7 +21,6 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.ObjectLists;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.ItemEntity;
@ -30,8 +29,8 @@ import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.capabilities.CapabilityToken;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.common.util.NonNullConsumer;
@ -152,7 +151,8 @@ public class CapabilityMinecartController implements ICapabilitySerializable<Com
if (!minecartController.isPresent())
continue;
AbstractMinecart cart = minecartController.cart();
if (cart.xChunk == chunkPos.x && cart.zChunk == chunkPos.z)
if (cart.chunkPosition()
.equals(chunkPos))
queuedUnloads.get(event.getWorld())
.add(cart.getUUID());
}
@ -206,8 +206,9 @@ public class CapabilityMinecartController implements ICapabilitySerializable<Com
/* Capability management */
@CapabilityInject(MinecartController.class)
public static Capability<MinecartController> MINECART_CONTROLLER_CAPABILITY = null;
public static Capability<MinecartController> MINECART_CONTROLLER_CAPABILITY =
CapabilityManager.get(new CapabilityToken<>() {
});
public static void attach(AttachCapabilitiesEvent<Entity> event) {
Entity entity = event.getObject();
@ -233,24 +234,6 @@ public class CapabilityMinecartController implements ICapabilitySerializable<Com
.ifPresent(MinecartController::sendData);
}
public static void register() {
CapabilityManager.INSTANCE.register(MinecartController.class, new Capability.IStorage<MinecartController>() {
@Override
public Tag writeNBT(Capability<MinecartController> capability, MinecartController instance,
Direction side) {
return instance.serializeNBT();
}
@Override
public void readNBT(Capability<MinecartController> capability, MinecartController instance, Direction side,
Tag base) {
instance.deserializeNBT((CompoundTag) base);
}
}, MinecartController::empty);
}
/* Capability provider */
private final LazyOptional<MinecartController> cap;

View file

@ -64,7 +64,7 @@ public class PotionFluid extends VirtualFluid {
}
public static FluidStack addPotionToFluidStack(FluidStack fs, Potion potion) {
ResourceLocation resourcelocation = ForgeRegistries.POTION_TYPES.getKey(potion);
ResourceLocation resourcelocation = ForgeRegistries.POTIONS.getKey(potion);
if (potion == Potions.EMPTY) {
fs.removeChildTag("Potion");
return fs;

View file

@ -51,7 +51,7 @@ public class PotionMixingRecipeManager {
Collection<ItemStack> reagents = getAllReagents(iBrewingRecipe);
Set<ItemStack> basicPotions = new HashSet<>();
for (Potion potion : ForgeRegistries.POTION_TYPES.getValues()) {
for (Potion potion : ForgeRegistries.POTIONS.getValues()) {
if (potion == Potions.EMPTY)
continue;
for (ItemStack stack : bottles)

View file

@ -219,14 +219,14 @@ public class GoggleOverlayRenderer {
super(p_i51108_1_);
}
@Override
public void init(Minecraft mc, int width, int height) {
this.minecraft = mc;
this.itemRenderer = mc.getItemRenderer();
this.font = mc.font;
this.width = width;
this.height = height;
}
// @Override
// public void init(Minecraft mc, int width, int height) {
// this.minecraft = mc;
// this.itemRenderer = mc.getItemRenderer();
// this.font = mc.font;
// this.width = width;
// this.height = height;
// }
}
}

View file

@ -1,13 +1,12 @@
package com.simibubi.create.content.contraptions.particle;
import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.minecraft.client.Camera;
import net.minecraft.client.multiplayer.ClientLevel;
@ -60,15 +59,13 @@ public class CubeParticle extends Particle {
RenderSystem.depthMask(false);
RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);
RenderSystem.enableLighting();
RenderSystem.enableColorMaterial();
// opaque
// RenderSystem.depthMask(true);
// RenderSystem.disableBlend();
// RenderSystem.enableLighting();
builder.begin(GL11.GL_QUADS, DefaultVertexFormat.BLOCK);
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK);
}
@Override
@ -76,7 +73,6 @@ public class CubeParticle extends Particle {
tessellator.end();
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA,
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.disableLighting();
RenderSystem.enableTexture();
}
};

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.relays.belt;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Consumer;
import org.apache.commons.lang3.mutable.MutableBoolean;
@ -24,10 +25,9 @@ import com.simibubi.create.content.schematics.ItemRequirement.ItemUseType;
import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult;
import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.ReducedDestroyEffects;
import net.minecraft.client.particle.ParticleEngine;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
@ -75,6 +75,7 @@ import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.IBlockRenderProperties;
import net.minecraftforge.common.Tags;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
@ -92,6 +93,11 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
.setValue(CASING, false));
}
@OnlyIn(Dist.CLIENT)
public void initializeClient(Consumer<IBlockRenderProperties> consumer) {
consumer.accept(new ReducedDestroyEffects());
}
@Override
public void fillItemCategory(CreativeModeTab p_149666_1_, NonNullList<ItemStack> p_149666_2_) {
p_149666_2_.add(AllItems.BELT_CONNECTOR.asStack());
@ -348,13 +354,6 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
return BlockPathTypes.RAIL;
}
@Override
@OnlyIn(Dist.CLIENT)
public boolean addDestroyEffects(BlockState state, Level world, BlockPos pos, ParticleEngine manager) {
BlockHelper.addReducedDestroyEffects(state, world, pos, manager);
return true;
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
return BeltShapes.getShape(state);
@ -377,8 +376,8 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
BeltTileEntity controller = te.getControllerTE();
if (controller == null)
return shape;
if (controller.passengers == null || !controller.passengers.containsKey(
((EntityCollisionContext) context).getEntity()
if (controller.passengers == null
|| !controller.passengers.containsKey(((EntityCollisionContext) context).getEntity()
.get()))
return BeltShapes.getCollisionShape(state);
return shape;

View file

@ -2,9 +2,11 @@ package com.simibubi.create.content.contraptions.relays.gauge;
import java.util.Random;
import com.mojang.math.Vector3f;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock;
import com.simibubi.create.content.contraptions.base.IRotate;
import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang;
@ -23,13 +25,14 @@ import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
public class GaugeBlock extends DirectionalAxisKineticBlock {
public class GaugeBlock extends DirectionalAxisKineticBlock implements ITE<GaugeTileEntity> {
public static final GaugeShaper GAUGE = GaugeShaper.make();
protected Type type;
@ -56,29 +59,6 @@ public class GaugeBlock extends DirectionalAxisKineticBlock {
this.type = type;
}
@Override
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
switch (type) {
case SPEED:
return AllTileEntities.SPEEDOMETER.create();
case STRESS:
return AllTileEntities.STRESSOMETER.create();
default:
return null;
}
}
/*
* FIXME: Is there a new way of doing this in 1.16? Or cn we just delete it?
*
* @SuppressWarnings("deprecation")
*
* @Override
* public MaterialColor getMaterialColor(BlockState state, IBlockReader worldIn, BlockPos pos) {
* return Blocks.SPRUCE_PLANKS.getMaterialColor(state, worldIn, pos);
* }
*/
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
Level world = context.getLevel();
@ -133,7 +113,7 @@ public class GaugeBlock extends DirectionalAxisKineticBlock {
return false;
if (getRotationAxis(state) == Axis.Y && face != state.getValue(FACING))
return false;
if (!Block.shouldRenderFace(state, world, pos, face) && !(world instanceof WrappedWorld))
if (!Block.shouldRenderFace(state, world, pos, face, pos.relative(face)) && !(world instanceof WrappedWorld))
return false;
return true;
}
@ -152,7 +132,7 @@ public class GaugeBlock extends DirectionalAxisKineticBlock {
if (!shouldRenderHeadOnFace(worldIn, pos, stateIn, face))
continue;
Vec3 rgb = Color.vectorFromRGB(color);
Vector3f rgb = new Vector3f(Color.vectorFromRGB(color));
Vec3 faceVec = Vec3.atLowerCornerOf(face.getNormal());
Direction positiveFacing = Direction.get(AxisDirection.POSITIVE, face.getAxis());
Vec3 positiveFaceVec = Vec3.atLowerCornerOf(positiveFacing.getNormal());
@ -169,8 +149,7 @@ public class GaugeBlock extends DirectionalAxisKineticBlock {
Vec3 offset = VecHelper.getCenterOf(pos)
.add(faceVec.scale(.55))
.add(mul);
worldIn.addParticle(new DustParticleOptions((float) rgb.x, (float) rgb.y, (float) rgb.z, 1), offset.x,
offset.y, offset.z, mul.x, mul.y, mul.z);
worldIn.addParticle(new DustParticleOptions(rgb, 1), offset.x, offset.y, offset.z, mul.x, mul.y, mul.z);
}
}
@ -201,4 +180,14 @@ public class GaugeBlock extends DirectionalAxisKineticBlock {
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
return false;
}
@Override
public Class<GaugeTileEntity> getTileEntityClass() {
return GaugeTileEntity.class;
}
@Override
public BlockEntityType<? extends GaugeTileEntity> getTileEntityType() {
return type == Type.SPEED ? AllTileEntities.SPEEDOMETER.get() : AllTileEntities.STRESSOMETER.get();
}
}

View file

@ -6,6 +6,7 @@ import java.util.List;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock;
import com.simibubi.create.foundation.block.ITE;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@ -17,23 +18,18 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.level.storage.loot.LootContext.Builder;
import net.minecraft.world.phys.HitResult;
public class GearboxBlock extends RotatedPillarKineticBlock {
public class GearboxBlock extends RotatedPillarKineticBlock implements ITE<GearboxTileEntity> {
public GearboxBlock(Properties properties) {
super(properties);
}
@Override
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
return AllTileEntities.GEARBOX.create();
}
@Override
public PushReaction getPistonPushReaction(BlockState state) {
return PushReaction.PUSH_ONLY;
@ -77,4 +73,14 @@ public class GearboxBlock extends RotatedPillarKineticBlock {
public Axis getRotationAxis(BlockState state) {
return state.getValue(AXIS);
}
@Override
public Class<GearboxTileEntity> getTileEntityClass() {
return GearboxTileEntity.class;
}
@Override
public BlockEntityType<? extends GearboxTileEntity> getTileEntityType() {
return AllTileEntities.GEARBOX.get();
}
}

View file

@ -2,6 +2,7 @@ package com.simibubi.create.content.curiosities;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeType;
public class CombustibleItem extends Item {
private int burnTime = -1;
@ -15,7 +16,8 @@ public class CombustibleItem extends Item {
}
@Override
public int getBurnTime(ItemStack itemStack) {
public int getBurnTime(ItemStack itemStack, RecipeType<?> recipeType) {
return this.burnTime;
}
}

View file

@ -43,7 +43,7 @@ public class ToolboxContainer extends ContainerBase<ToolboxTileEntity> {
BlockEntity tileEntity = world.getBlockEntity(readBlockPos);
if (tileEntity instanceof ToolboxTileEntity) {
ToolboxTileEntity toolbox = (ToolboxTileEntity) tileEntity;
toolbox.handleUpdateTag(toolbox.getBlockState(), readNbt);
toolbox.handleUpdateTag(readNbt);
return toolbox;
}
@ -73,20 +73,18 @@ public class ToolboxContainer extends ContainerBase<ToolboxTileEntity> {
}
@Override
public ItemStack clicked(int index, int flags, ClickType type, Player player) {
public void clicked(int index, int flags, ClickType type, Player player) {
int size = contentHolder.inventory.getSlots();
if (index >= 0 && index < size) {
ItemStack itemInClickedSlot = getSlot(index).getItem();
Inventory playerInv = player.getInventory();
ItemStack carried = playerInv.getCarried();
ItemStack carried = getCarried();
if (type == ClickType.PICKUP && !carried.isEmpty() && !itemInClickedSlot.isEmpty()
&& ToolboxInventory.canItemsShareCompartment(itemInClickedSlot, carried)) {
int subIndex = index % STACKS_PER_COMPARTMENT;
if (subIndex != STACKS_PER_COMPARTMENT - 1)
return clicked(index - subIndex + STACKS_PER_COMPARTMENT - 1, flags, type, player);
clicked(index - subIndex + STACKS_PER_COMPARTMENT - 1, flags, type, player);
}
if (type == ClickType.PICKUP && carried.isEmpty() && itemInClickedSlot.isEmpty())
@ -96,7 +94,7 @@ public class ToolboxContainer extends ContainerBase<ToolboxTileEntity> {
}
}
return super.clicked(index, flags, type, player);
super.clicked(index, flags, type, player);
}
@Override

View file

@ -30,10 +30,8 @@ public class ToolboxDyeingRecipe extends CustomRecipe {
if (Block.byItem(stack.getItem()) instanceof ToolboxBlock) {
++toolboxes;
} else {
if (!stack.getItem().is(Tags.Items.DYES)) {
if (!stack.is(Tags.Items.DYES))
return false;
}
++dyes;
}
@ -65,9 +63,11 @@ public class ToolboxDyeingRecipe extends CustomRecipe {
}
}
ItemStack dyedToolbox = AllBlocks.TOOLBOXES.get(color).asStack();
ItemStack dyedToolbox = AllBlocks.TOOLBOXES.get(color)
.asStack();
if (toolbox.hasTag()) {
dyedToolbox.setTag(toolbox.getTag().copy());
dyedToolbox.setTag(toolbox.getTag()
.copy());
}
return dyedToolbox;

View file

@ -6,7 +6,7 @@ import java.util.stream.Collectors;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.networking.ISyncPersistentData;
import com.simibubi.create.foundation.networking.ISyncPersistentData.PersistentDataPacket;
import com.simibubi.create.foundation.utility.WorldAttached;
import net.minecraft.core.BlockPos;
@ -98,7 +98,7 @@ public class ToolboxHandler {
public static void syncData(Player player) {
AllPackets.channel.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player),
new ISyncPersistentData.Packet(player));
new PersistentDataPacket(player));
}
public static List<ToolboxTileEntity> getNearest(LevelAccessor world, Player player, int maxAmount) {

View file

@ -25,7 +25,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.tags.SerializationTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.Item;
@ -104,9 +104,11 @@ public class BlueprintOverlayRenderer {
boolean firstPass = true;
boolean success = true;
Minecraft mc = Minecraft.getInstance();
ItemStackHandler playerInv = new ItemStackHandler(mc.player.getInventory().getContainerSize());
ItemStackHandler playerInv = new ItemStackHandler(mc.player.getInventory()
.getContainerSize());
for (int i = 0; i < playerInv.getSlots(); i++)
playerInv.setStackInSlot(i, mc.player.getInventory().getItem(i)
playerInv.setStackInSlot(i, mc.player.getInventory()
.getItem(i)
.copy());
int amountCrafted = 0;
@ -278,8 +280,7 @@ public class BlueprintOverlayRenderer {
ItemAttribute fromNBT = ItemAttribute.fromNBT((CompoundTag) attributes.get(0));
if (fromNBT instanceof ItemAttribute.InTag) {
ItemAttribute.InTag inTag = (ItemAttribute.InTag) fromNBT;
Tag<Item> itag = SerializationTags.getInstance()
.getItems()
Tag<Item> itag = ItemTags.getAllTags()
.getTag(inTag.tagName);
if (itag != null)
return Ingredient.of(itag)

View file

@ -54,20 +54,22 @@ public class ExtendoGripInteractionPacket extends SimplePacketBase {
@Override
public void handle(Supplier<Context> context) {
context.get().enqueueWork(() -> {
ServerPlayer sender = context.get().getSender();
context.get()
.enqueueWork(() -> {
ServerPlayer sender = context.get()
.getSender();
if (sender == null)
return;
Entity entityByID = sender.getLevel().getEntity(target);
Entity entityByID = sender.getLevel()
.getEntity(target);
if (entityByID != null && ExtendoGripItem.isHoldingExtendoGrip(sender)) {
double d = sender.getAttribute(ForgeMod.REACH_DISTANCE.get()).getValue();
if (!sender.canSee(entityByID))
double d = sender.getAttribute(ForgeMod.REACH_DISTANCE.get())
.getValue();
if (!sender.hasLineOfSight(entityByID))
d -= 3;
d *= d;
if (sender.distanceToSqr(entityByID) > d) {
// TODO log?
if (sender.distanceToSqr(entityByID) > d)
return;
}
if (interactionHand == null)
sender.attack(entityByID);
else if (specificPoint == null)
@ -76,7 +78,8 @@ public class ExtendoGripInteractionPacket extends SimplePacketBase {
entityByID.interactAt(sender, specificPoint, interactionHand);
}
});
context.get().setPacketHandled(true);
context.get()
.setPacketHandled(true);
}
}

View file

@ -102,7 +102,7 @@ public class SandPaperItem extends Item {
itemstack.getOrCreateTag()
.put("Polishing", toPolish.serializeNBT());
if (item.isEmpty())
pickUp.remove();
pickUp.discard();
else
pickUp.setItem(item);
}
@ -143,7 +143,7 @@ public class SandPaperItem extends Item {
if (player instanceof FakePlayer) {
player.drop(polished, false, false);
} else {
player.getInventory().placeItemBackInInventory(worldIn, polished);
player.getInventory().placeItemBackInInventory(polished);
}
}
tag.remove("Polishing");
@ -169,7 +169,7 @@ public class SandPaperItem extends Item {
CompoundTag tag = stack.getOrCreateTag();
if (tag.contains("Polishing")) {
ItemStack toPolish = ItemStack.of(tag.getCompound("Polishing"));
player.getInventory().placeItemBackInInventory(worldIn, toPolish);
player.getInventory().placeItemBackInInventory(toPolish);
tag.remove("Polishing");
}
}

View file

@ -134,7 +134,7 @@ public class PotatoProjectileEntity extends AbstractHurtingProjectile implements
if (stuckEntity != null) {
if (getY() < stuckEntity.getY() - 0.1) {
pop(position());
remove();
kill();
} else {
stuckFallSpeed += 0.007 * projectileType.getGravityMultiplier();
stuckOffset = stuckOffset.add(0, -stuckFallSpeed, 0);
@ -201,7 +201,7 @@ public class PotatoProjectileEntity extends AbstractHurtingProjectile implements
boolean onServer = !level.isClientSide;
if (onServer && !target.hurt(causePotatoDamage(), damage)) {
target.setRemainingFireTicks(k);
remove();
kill();
return;
}
@ -214,7 +214,7 @@ public class PotatoProjectileEntity extends AbstractHurtingProjectile implements
if (!(target instanceof LivingEntity)) {
playHitSound(level, position());
remove();
kill();
return;
}
@ -254,7 +254,7 @@ public class PotatoProjectileEntity extends AbstractHurtingProjectile implements
if (type.isSticky() && target.isAlive()) {
setStuckEntity(target);
} else {
remove();
kill();
}
}
@ -280,7 +280,7 @@ public class PotatoProjectileEntity extends AbstractHurtingProjectile implements
if (random.nextDouble() <= recoveryChance)
recoverItem();
super.onHitBlock(ray);
remove();
kill();
}
@Override
@ -290,7 +290,7 @@ public class PotatoProjectileEntity extends AbstractHurtingProjectile implements
if (this.isInvulnerableTo(source))
return false;
pop(position());
remove();
kill();
return true;
}

View file

@ -34,7 +34,7 @@ public interface PotatoProjectileRenderMode {
MatrixTransformStack.of(ms)
.rotateY(AngleHelper.deg(Mth.atan2(diff.x, diff.z)) + 180)
.rotateX(AngleHelper.deg(Mth.atan2(diff.y, Mth.sqrt(diff.x * diff.x + diff.z * diff.z))));
.rotateX(AngleHelper.deg(Mth.atan2(diff.y, Mth.sqrt((float) (diff.x * diff.x + diff.z * diff.z)))));
}
}
@ -71,7 +71,7 @@ public interface PotatoProjectileRenderMode {
MatrixTransformStack.of(ms)
.rotateY(AngleHelper.deg(Mth.atan2(diff.x, diff.z)))
.rotateX(270
+ AngleHelper.deg(Mth.atan2(diff.y, -Mth.sqrt(diff.x * diff.x + diff.z * diff.z))));
+ AngleHelper.deg(Mth.atan2(diff.y, -Mth.sqrt((float) (diff.x * diff.x + diff.z * diff.z)))));
MatrixTransformStack.of(ms)
.rotateY((entity.tickCount + pt) * 20 * spin + entityRandom(entity, 360))
.rotateZ(-spriteAngleOffset);

View file

@ -228,7 +228,7 @@ public abstract class ZapperItem extends Item {
data.putInt("x", pos.getX());
data.putInt("y", pos.getY());
data.putInt("z", pos.getZ());
tile.load(state, data);
tile.load(data);
}
}
}

View file

@ -1,5 +1,7 @@
package com.simibubi.create.content.logistics.block.chute;
import java.util.function.Consumer;
import javax.annotation.Nullable;
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
@ -7,10 +9,9 @@ import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.ReducedDestroyEffects;
import net.minecraft.client.particle.ParticleEngine;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
@ -23,13 +24,13 @@ import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.IBlockRenderProperties;
import net.minecraftforge.common.util.LazyOptional;
public abstract class AbstractChuteBlock extends Block implements IWrenchable, ITE<ChuteTileEntity> {
@ -38,6 +39,11 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I
super(p_i48440_1_);
}
@OnlyIn(Dist.CLIENT)
public void initializeClient(Consumer<IBlockRenderProperties> consumer) {
consumer.accept(new ReducedDestroyEffects());
}
public static boolean isChute(BlockState state) {
return state.getBlock() instanceof AbstractChuteBlock;
}
@ -164,13 +170,6 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I
public abstract BlockState updateChuteState(BlockState state, BlockState above, BlockGetter world, BlockPos pos);
@Override
@OnlyIn(Dist.CLIENT)
public boolean addDestroyEffects(BlockState state, Level world, BlockPos pos, ParticleEngine manager) {
BlockHelper.addReducedDestroyEffects(state, world, pos, manager);
return true;
}
@Override
public VoxelShape getShape(BlockState p_220053_1_, BlockGetter p_220053_2_, BlockPos p_220053_3_,
CollisionContext p_220053_4_) {

View file

@ -1,6 +1,7 @@
package com.simibubi.create.content.logistics.block.funnel;
import java.util.Random;
import java.util.function.Consumer;
import javax.annotation.Nullable;
@ -10,9 +11,8 @@ import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipulationBehaviour;
import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.ReducedDestroyEffects;
import net.minecraft.client.particle.ParticleEngine;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
@ -31,6 +31,7 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.IBlockRenderProperties;
public abstract class AbstractFunnelBlock extends Block implements ITE<FunnelTileEntity>, IWrenchable {
@ -41,6 +42,11 @@ public abstract class AbstractFunnelBlock extends Block implements ITE<FunnelTil
registerDefaultState(defaultBlockState().setValue(POWERED, false));
}
@OnlyIn(Dist.CLIENT)
public void initializeClient(Consumer<IBlockRenderProperties> consumer) {
consumer.accept(new ReducedDestroyEffects());
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
return defaultBlockState().setValue(POWERED, context.getLevel()
@ -57,13 +63,6 @@ public abstract class AbstractFunnelBlock extends Block implements ITE<FunnelTil
super.createBlockStateDefinition(builder.add(POWERED));
}
@Override
@OnlyIn(Dist.CLIENT)
public boolean addDestroyEffects(BlockState state, Level world, BlockPos pos, ParticleEngine manager) {
BlockHelper.addReducedDestroyEffects(state, world, pos, manager);
return true;
}
@Override
public void neighborChanged(BlockState state, Level worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {

View file

@ -50,8 +50,7 @@ public class NixieTubeRenderer extends SafeTileEntityRenderer<NixieTubeTileEntit
.build();
public NixieTubeRenderer(BlockEntityRendererProvider.Context context) {
}
public NixieTubeRenderer(BlockEntityRendererProvider.Context context) {}
@Override
protected void renderSafe(NixieTubeTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
@ -120,7 +119,7 @@ public class NixieTubeRenderer extends SafeTileEntityRenderer<NixieTubeTileEntit
if (buffer instanceof BufferSource) {
BakedGlyph texturedglyph = fontRenderer.getFontSet(Style.DEFAULT_FONT)
.whiteGlyph();
((BufferSource) buffer).endBatch(texturedglyph.renderType(false));
((BufferSource) buffer).endBatch(texturedglyph.renderType(Font.DisplayMode.NORMAL));
}
}

View file

@ -32,6 +32,7 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.GlassBlock;
import net.minecraft.world.level.block.SandBlock;
import net.minecraft.world.level.block.state.properties.WoodType;
import net.minecraft.world.level.storage.loot.entries.LootItem;
import net.minecraftforge.common.Tags;
public class AllPaletteBlocks {
@ -102,8 +103,8 @@ public class AllPaletteBlocks {
public static final PalettesVariantEntry DIORITE_VARIANTS =
new PalettesVariantEntry(PaletteStoneVariants.DIORITE, PaletteBlockPattern.VANILLA_RANGE);
public static final PalettesVariantEntry ANDESITE_VARIANTS = new PalettesVariantEntry(PaletteStoneVariants.ANDESITE,
PaletteBlockPattern.VANILLA_RANGE);
public static final PalettesVariantEntry ANDESITE_VARIANTS =
new PalettesVariantEntry(PaletteStoneVariants.ANDESITE, PaletteBlockPattern.VANILLA_RANGE);
// Create stone variants
@ -126,8 +127,8 @@ public class AllPaletteBlocks {
.loot(cobblestoneLoot(PaletteStoneVariants.WEATHERED_LIMESTONE))
.register();
public static final PalettesVariantEntry WEATHERED_LIMESTONE_VARIANTS = new PalettesVariantEntry(
PaletteStoneVariants.WEATHERED_LIMESTONE, PaletteBlockPattern.STANDARD_RANGE);
public static final PalettesVariantEntry WEATHERED_LIMESTONE_VARIANTS =
new PalettesVariantEntry(PaletteStoneVariants.WEATHERED_LIMESTONE, PaletteBlockPattern.STANDARD_RANGE);
public static final BlockEntry<Block> DOLOMITE =
REGISTRATE.paletteStoneBlock("dolomite", () -> Blocks.QUARTZ_BLOCK, true)
@ -137,16 +138,14 @@ public class AllPaletteBlocks {
public static final PalettesVariantEntry DOLOMITE_VARIANTS =
new PalettesVariantEntry(PaletteStoneVariants.DOLOMITE, PaletteBlockPattern.STANDARD_RANGE);
public static final BlockEntry<Block> GABBRO =
REGISTRATE.paletteStoneBlock("gabbro", () -> Blocks.ANDESITE, true)
public static final BlockEntry<Block> GABBRO = REGISTRATE.paletteStoneBlock("gabbro", () -> Blocks.ANDESITE, true)
.loot(cobblestoneLoot(PaletteStoneVariants.GABBRO))
.register();
public static final PalettesVariantEntry GABBRO_VARIANTS =
new PalettesVariantEntry(PaletteStoneVariants.GABBRO, PaletteBlockPattern.STANDARD_RANGE);
public static final BlockEntry<Block> SCORIA =
REGISTRATE.paletteStoneBlock("scoria", () -> Blocks.ANDESITE, false)
public static final BlockEntry<Block> SCORIA = REGISTRATE.paletteStoneBlock("scoria", () -> Blocks.ANDESITE, false)
.loot(cobblestoneLoot(PaletteStoneVariants.SCORIA))
.register();
@ -154,7 +153,8 @@ public class AllPaletteBlocks {
.initialProperties(() -> Blocks.ANDESITE)
.tag(BlockTags.BASE_STONE_OVERWORLD, AllTags.AllBlockTags.WG_STONE.tag)
.onRegister(CreateRegistrate.blockVertexColors(ScoriaVertexColor.INSTANCE))
.loot((p, g) -> p.add(g, RegistrateBlockLootTables.droppingWithSilkTouch(g, SCORIA.get())))
.loot((p, g) -> p.add(g,
RegistrateBlockLootTables.createSilkTouchDispatchTable(g, LootItem.lootTableItem(SCORIA.get()))))
.blockstate(palettesCubeAll())
.simpleItem()
.register();
@ -170,9 +170,12 @@ public class AllPaletteBlocks {
public static final PalettesVariantEntry DARK_SCORIA_VARIANTS =
new PalettesVariantEntry(PaletteStoneVariants.DARK_SCORIA, PaletteBlockPattern.STANDARD_RANGE);
private static <T extends Block> NonNullBiConsumer<RegistrateBlockLootTables, T> cobblestoneLoot(PaletteStoneVariants variant) {
return (loot, block) -> loot.add(block, RegistrateBlockLootTables.droppingWithSilkTouch(block,
variant.getVariants().registeredBlocks.get(0).get()));
private static <T extends Block> NonNullBiConsumer<RegistrateBlockLootTables, T> cobblestoneLoot(
PaletteStoneVariants variant) {
return (loot, block) -> loot.add(block,
RegistrateBlockLootTables.createSilkTouchDispatchTable(block,
LootItem.lootTableItem(variant.getVariants().registeredBlocks.get(0)
.get())));
}
private static <T extends Block> NonNullBiConsumer<DataGenContext<Block, T>, RegistrateBlockstateProvider> palettesCubeAll() {

View file

@ -186,7 +186,7 @@ public abstract class PaletteBlockPartial<B extends Block> {
protected BlockBuilder<SlabBlock, CreateRegistrate> transformBlock(
BlockBuilder<SlabBlock, CreateRegistrate> builder,
String variantName, PaletteBlockPattern pattern) {
builder.loot((lt, block) -> lt.add(block, RegistrateBlockLootTables.droppingSlab(block)));
builder.loot((lt, block) -> lt.add(block, RegistrateBlockLootTables.createSlabItemTable(block)));
return super.transformBlock(builder, variantName, pattern);
}

View file

@ -32,6 +32,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;
import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent;
import net.minecraftforge.event.AddReloadListenerEvent;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.RegisterCommandsEvent;

View file

@ -72,8 +72,8 @@ public class CloneCommand {
if (!world.hasChunksAt(begin, end) || !world.hasChunksAt(destination, destinationEnd))
throw BlockPosArgument.ERROR_NOT_LOADED.create();
BlockPos diffToTarget = new BlockPos(destinationArea.x0 - sourceArea.x0,
destinationArea.y0 - sourceArea.y0, destinationArea.z0 - sourceArea.z0);
BlockPos diffToTarget = new BlockPos(destinationArea.minX() - sourceArea.minX(),
destinationArea.minY() - sourceArea.minY(), destinationArea.minZ() - sourceArea.minZ());
int blockPastes = cloneBlocks ? cloneBlocks(sourceArea, world, diffToTarget) : 0;
int gluePastes = cloneGlue(sourceArea, world, diffToTarget);
@ -89,8 +89,7 @@ public class CloneCommand {
private static int cloneGlue(BoundingBox sourceArea, ServerLevel world, BlockPos diffToTarget) {
int gluePastes = 0;
List<SuperGlueEntity> glue =
world.getEntitiesOfClass(SuperGlueEntity.class, AABB.of(sourceArea));
List<SuperGlueEntity> glue = world.getEntitiesOfClass(SuperGlueEntity.class, AABB.of(sourceArea));
List<Pair<BlockPos, Direction>> newGlue = Lists.newArrayList();
for (SuperGlueEntity g : glue) {
@ -115,9 +114,9 @@ public class CloneCommand {
List<StructureTemplate.StructureBlockInfo> blocks = Lists.newArrayList();
List<StructureTemplate.StructureBlockInfo> tileBlocks = Lists.newArrayList();
for (int z = sourceArea.z0; z <= sourceArea.z1; ++z) {
for (int y = sourceArea.y0; y <= sourceArea.y1; ++y) {
for (int x = sourceArea.x0; x <= sourceArea.x1; ++x) {
for (int z = sourceArea.minZ(); z <= sourceArea.maxZ(); ++z) {
for (int y = sourceArea.minY(); y <= sourceArea.maxY(); ++y) {
for (int x = sourceArea.minX(); x <= sourceArea.maxX(); ++x) {
BlockPos currentPos = new BlockPos(x, y, z);
BlockPos newPos = currentPos.offset(diffToTarget);
BlockInWorld cached = new BlockInWorld(world, currentPos, false);
@ -156,11 +155,12 @@ public class CloneCommand {
info.nbt.putInt("x", info.pos.getX());
info.nbt.putInt("y", info.pos.getY());
info.nbt.putInt("z", info.pos.getZ());
te.load(info.state, info.nbt);
te.load(info.nbt);
te.setChanged();
}
// idk why the state is set twice for a te, but its done like this in the original clone command
// idk why the state is set twice for a te, but its done like this in the
// original clone command
world.setBlock(info.pos, info.state, 2);
}

View file

@ -119,6 +119,7 @@ public class AllIcons implements IScreenRenderable {
I_FOLLOW_MATERIAL = next(),
I_SCHEMATIC = newRow(),
I_SEQ_REPEAT = next(),
I_MTD_LEFT = newRow(),
I_MTD_CLOSE = next(),

View file

@ -50,12 +50,14 @@ public abstract class GhostItemContainer<T> extends ContainerBase<T> implements
}
@Override
public ItemStack clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) {
ItemStack held = playerInventory.getCarried();
if (slotId < 36)
return super.clicked(slotId, dragType, clickTypeIn, player);
public void clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) {
ItemStack held = getCarried();
if (slotId < 36) {
super.clicked(slotId, dragType, clickTypeIn, player);
return;
}
if (clickTypeIn == ClickType.THROW)
return ItemStack.EMPTY;
return;
int slot = slotId - 36;
if (clickTypeIn == ClickType.CLONE) {
@ -63,23 +65,23 @@ public abstract class GhostItemContainer<T> extends ContainerBase<T> implements
ItemStack stackInSlot = ghostInventory.getStackInSlot(slot)
.copy();
stackInSlot.setCount(stackInSlot.getMaxStackSize());
playerInventory.setCarried(stackInSlot);
return ItemStack.EMPTY;
setCarried(stackInSlot);
return;
}
return ItemStack.EMPTY;
return;
}
if (held.isEmpty()) {
ghostInventory.setStackInSlot(slot, ItemStack.EMPTY);
getSlot(slotId).setChanged();
return ItemStack.EMPTY;
return;
}
ItemStack insert = held.copy();
insert.setCount(1);
ghostInventory.setStackInSlot(slot, insert);
getSlot(slotId).setChanged();
return held;
setCarried(held);
}
@Override

View file

@ -158,7 +158,7 @@ public class BearingScenes {
scene.title("windmill_structure", "Windmill Contraptions");
scene.configureBasePlate(1, 1, 5);
scene.setSceneOffsetY(-1);
scene.world.modifyEntities(SuperGlueEntity.class, Entity::remove);
scene.world.modifyEntities(SuperGlueEntity.class, Entity::discard);
scene.world.showSection(util.select.layer(0), Direction.UP);
scene.idle(5);

View file

@ -336,7 +336,7 @@ public class BeltScenes {
ElementLink<EntityElement> item =
scene.world.createItemEntity(util.vector.centerOf(0, 4, 2), util.vector.of(0, 0, 0), stack);
scene.idle(13);
scene.world.modifyEntity(item, Entity::remove);
scene.world.modifyEntity(item, Entity::discard);
BlockPos beltEnd = util.grid.at(0, 1, 2);
scene.world.createItemOnBelt(beltEnd, Direction.DOWN, stack);
@ -358,7 +358,7 @@ public class BeltScenes {
scene.idle(10);
scene.special.movePointOfInterest(beltEnd);
scene.idle(3);
scene.world.modifyEntity(item, Entity::remove);
scene.world.modifyEntity(item, Entity::discard);
scene.world.createItemOnBelt(beltEnd, Direction.DOWN, stack);
scene.idle(8);
@ -373,7 +373,7 @@ public class BeltScenes {
scene.idle(5);
scene.world.setKineticSpeed(util.select.everywhere(), 0f);
scene.idle(10);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.special.movePointOfInterest(util.grid.at(2, 5, 4));
Vec3 topOf = util.vector.topOf(util.grid.at(3, 2, 2))

View file

@ -155,7 +155,7 @@ public class CartAssemblerScenes {
.pointAt(cartCenter)
.placeNearTarget();
scene.idle(80);
scene.world.modifyEntity(itemEntity, Entity::remove);
scene.world.modifyEntity(itemEntity, Entity::discard);
scene.overlay.showControls(new InputWindowElement(cartCenter.add(0, 0, 4), Pointing.DOWN).rightClick()
.withItem(asStack), 20);

View file

@ -261,7 +261,7 @@ public class ChassisScenes {
scene.effects.superGlue(chassisPos.west(), Direction.NORTH, true);
scene.idle(20);
scene.world.modifyEntity(glueEntity, Entity::remove);
scene.world.modifyEntity(glueEntity, Entity::discard);
scene.world.hideIndependentSection(glassSection, Direction.UP);
scene.world.hideIndependentSection(gluedPlank, Direction.UP);
scene.world.hideIndependentSection(topGlassSection, Direction.UP);
@ -509,7 +509,7 @@ public class ChassisScenes {
scene.world.glueBlockOnto(central.north(), Direction.SOUTH, plank);
scene.idle(20);
scene.world.modifyEntity(glueEntity, Entity::remove);
scene.world.modifyEntity(glueEntity, Entity::discard);
BlockPos bearingPos = util.grid.at(2, 1, 2);
scene.world.configureCenterOfRotation(plank, util.vector.centerOf(bearingPos));
@ -558,7 +558,7 @@ public class ChassisScenes {
scene.addKeyframe();
scene.overlay.showControls(new InputWindowElement(util.vector.topOf(central), Pointing.DOWN).leftClick(), 40);
scene.idle(7);
scene.world.modifyEntity(glueEntity, Entity::remove);
scene.world.modifyEntity(glueEntity, Entity::discard);
scene.effects.superGlue(central, Direction.UP, false);
scene.idle(10);
scene.overlay.showText(60)

View file

@ -47,7 +47,7 @@ public class ChuteScenes {
ElementLink<EntityElement> remove =
scene.world.createItemEntity(util.vector.centerOf(util.grid.at(1, 5, 2)), util.vector.of(0, 0.1, 0), stack);
scene.idle(15);
scene.world.modifyEntity(remove, Entity::remove);
scene.world.modifyEntity(remove, Entity::discard);
scene.overlay.showText(60)
.attachKeyFrame()
@ -55,7 +55,7 @@ public class ChuteScenes {
.placeNearTarget()
.text("Chutes can transport items vertically from and to inventories");
scene.idle(70);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.world.moveSection(bottom, util.vector.of(1, 0, 0), 10);
scene.world.moveSection(top, util.vector.of(-1, 0, 0), 10);
scene.idle(20);
@ -125,7 +125,7 @@ public class ChuteScenes {
stack);
scene.idle(12);
scene.world.createItemOnBeltLike(util.grid.at(2, 4, 3), Direction.UP, stack);
scene.world.modifyEntity(remove, Entity::remove);
scene.world.modifyEntity(remove, Entity::discard);
scene.idle(3);
offset = offset.getClockWise();
}

View file

@ -434,17 +434,17 @@ public class CrafterScenes {
ElementLink<EntityElement> ingot =
scene.world.createItemEntity(util.vector.centerOf(4, 4, 2), util.vector.of(0, 0.2, 0), iron);
scene.idle(17);
scene.world.modifyEntity(ingot, Entity::remove);
scene.world.modifyEntity(ingot, Entity::discard);
scene.world.modifyTileEntity(util.grid.at(3, 2, 2), type, mct -> mct.getInventory()
.insertItem(0, iron.copy(), false));
ingot = scene.world.createItemEntity(util.vector.centerOf(4, 4, 2), util.vector.of(0, 0.2, 0), iron);
scene.idle(17);
scene.world.modifyEntity(ingot, Entity::remove);
scene.world.modifyEntity(ingot, Entity::discard);
scene.world.modifyTileEntity(util.grid.at(2, 1, 2), type, mct -> mct.getInventory()
.insertItem(0, iron.copy(), false));
ingot = scene.world.createItemEntity(util.vector.centerOf(4, 4, 2), util.vector.of(0, 0.2, 0), iron);
scene.idle(17);
scene.world.modifyEntity(ingot, Entity::remove);
scene.world.modifyEntity(ingot, Entity::discard);
scene.world.modifyTileEntity(util.grid.at(1, 2, 2), type, mct -> mct.getInventory()
.insertItem(0, iron.copy(), false));

View file

@ -431,7 +431,7 @@ public class DebugScenes {
scene.idle(27);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
}
public static void pipeScene(SceneBuilder scene, SceneBuildingUtil util) {

View file

@ -127,7 +127,7 @@ public class EjectorScenes {
.placeNearTarget();
scene.idle(60);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.world.hideSection(targetS, Direction.SOUTH);
scene.idle(15);
scene.world.restoreBlocks(targetS);
@ -187,7 +187,7 @@ public class EjectorScenes {
scene.world.hideSection(util.select.fromTo(5, 1, 0, 4, 1, 1), Direction.UP);
scene.world.hideSection(util.select.position(5, 0, 1), Direction.DOWN);
scene.idle(30);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.addKeyframe();
ElementLink<ParrotElement> birb = scene.special.createBirb(util.vector.topOf(ejectorPos)
@ -309,7 +309,7 @@ public class EjectorScenes {
for (int i = 0; i < 3; i++) {
scene.world.createItemEntity(topOf, util.vector.of(0, 0.1, 0), copper);
scene.idle(12);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.world.createItemOnBeltLike(ejectorPos, Direction.UP, copper);
scene.idle(20);
if (i == 1) {
@ -349,7 +349,7 @@ public class EjectorScenes {
for (int i = 0; i < 6; i++) {
scene.world.createItemEntity(topOf, util.vector.of(0, 0.1, 0), copper);
scene.idle(12);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.world.createItemOnBeltLike(ejectorPos, Direction.UP, copper);
scene.idle(1);
scene.world.toggleRedstonePower(observerRedstone);

View file

@ -137,7 +137,7 @@ public class FanScenes {
scene.idle(40);
scene.overlay.showControls(new InputWindowElement(itemVec, Pointing.DOWN).withItem(smelted), 20);
scene.idle(20);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.idle(20);
scene.overlay.showText(80)
@ -202,7 +202,7 @@ public class FanScenes {
scene.world.modifyEntities(ItemEntity.class, ie -> ie.setItem(washed));
scene.overlay.showControls(new InputWindowElement(itemVec, Pointing.DOWN).withItem(washed), 20);
scene.idle(20);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.idle(20);
scene.overlay.showText(100)

View file

@ -79,7 +79,7 @@ public class FunnelScenes {
for (int i = 0; i < 4; i++) {
if (lastItemEntity != null)
scene.world.modifyEntity(lastItemEntity, Entity::remove);
scene.world.modifyEntity(lastItemEntity, Entity::discard);
if (i < 3)
lastItemEntity = scene.world.createItemEntity(topItemSpawn, util.vector.of(0, -0.4, 0), itemStack);
scene.idle(8);
@ -139,7 +139,7 @@ public class FunnelScenes {
scene.world.createItemEntity(topCenter, util.vector.of(0, 4 / 16f, 0), itemStack);
scene.idle(40);
scene.world.modifyEntity(itemLink, Entity::remove);
scene.world.modifyEntity(itemLink, Entity::discard);
scene.world.hideSection(topFunnelSelection, Direction.UP);
scene.idle(20);
@ -159,7 +159,7 @@ public class FunnelScenes {
itemLink = scene.world.createItemEntity(topCenter.add(0, 3, 0), util.vector.of(0, -0.2, 0), itemStack);
scene.idle(10);
scene.world.modifyEntity(itemLink, Entity::remove);
scene.world.modifyEntity(itemLink, Entity::discard);
scene.idle(45);
// Wrench interaction
@ -182,7 +182,7 @@ public class FunnelScenes {
scene.idle(10);
scene.world.modifyBlock(topFunnel, s -> s.cycle(FunnelBlock.EXTRACTING), true);
scene.idle(10);
scene.world.modifyEntity(itemLink, Entity::remove);
scene.world.modifyEntity(itemLink, Entity::discard);
scene.idle(20);
@ -205,7 +205,7 @@ public class FunnelScenes {
scene.idle(60);
scene.world.hideSection(sideFunnelSelection, Direction.UP);
scene.world.hideSection(topFunnelSelection, Direction.UP);
scene.world.modifyEntity(itemLink, Entity::remove);
scene.world.modifyEntity(itemLink, Entity::discard);
scene.idle(20);
// Belt funnel
@ -324,7 +324,7 @@ public class FunnelScenes {
for (int i = 0; i < 4; i++) {
if (lastItemEntity != null)
scene.world.modifyEntity(lastItemEntity, Entity::remove);
scene.world.modifyEntity(lastItemEntity, Entity::discard);
lastItemEntity = scene.world.createItemEntity(topItemSpawn, util.vector.of(0, -0.2, 0), itemStack);
scene.idle(8);

View file

@ -56,7 +56,7 @@ public class MechanicalDrillScenes {
scene.idle(20);
scene.idle(15);
scene.world.modifyEntity(plankEntity, Entity::remove);
scene.world.modifyEntity(plankEntity, Entity::discard);
scene.world.modifyKineticSpeed(util.select.everywhere(), f -> 4 * f);
scene.effects.rotationSpeedIndicator(breakingPos.east(3));
scene.idle(5);
@ -162,7 +162,7 @@ public class MechanicalDrillScenes {
scene.idle(40);
scene.world.setBlocks(planks, Blocks.OAK_PLANKS.defaultBlockState(), false);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.world.glueBlockOnto(util.grid.at(4, 3, 2), Direction.DOWN, contraption);
scene.overlay.showText(60)

View file

@ -65,7 +65,7 @@ public class MechanicalSawScenes {
scene.world.modifyEntity(logItem, e -> e.setDeltaMovement(util.vector.of(0.05, 0.2, 0)));
scene.idle(12);
scene.world.modifyEntity(logItem, Entity::remove);
scene.world.modifyEntity(logItem, Entity::discard);
scene.world.createItemOnBeltLike(sawPos, Direction.WEST, log);
scene.idle(50);
@ -88,7 +88,7 @@ public class MechanicalSawScenes {
scene.world.modifyEntity(logItem, e -> e.setDeltaMovement(util.vector.of(-0.05, 0.2, 0)));
scene.idle(12);
scene.world.modifyEntity(logItem, Entity::remove);
scene.world.modifyEntity(logItem, Entity::discard);
scene.world.createItemOnBeltLike(sawPos, Direction.EAST, strippedLog);
scene.idle(25);
@ -102,7 +102,7 @@ public class MechanicalSawScenes {
scene.world.setKineticSpeed(otherBelt, 0);
scene.world.setKineticSpeed(belt, 0);
scene.world.modifyKineticSpeed(util.select.everywhere(), f -> -f);
scene.world.modifyEntity(logItem, Entity::remove);
scene.world.modifyEntity(logItem, Entity::discard);
scene.world.setBlock(shaftPos, AllBlocks.COGWHEEL.getDefaultState()
.setValue(ShaftBlock.AXIS, Axis.Z), true);
scene.idle(3);
@ -144,7 +144,7 @@ public class MechanicalSawScenes {
scene.overlay.showFilterSlotInput(filter, 80);
ItemStack bricks = new ItemStack(Blocks.STONE_BRICKS);
scene.overlay.showControls(new InputWindowElement(filter, Pointing.DOWN).withItem(bricks), 80);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.idle(7);
scene.world.setFilterData(util.select.position(sawPos), SawTileEntity.class, bricks);
scene.idle(10);
@ -167,7 +167,7 @@ public class MechanicalSawScenes {
.pointAt(filter)
.placeNearTarget();
scene.idle(65);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
}
public static void treeCutting(SceneBuilder scene, SceneBuildingUtil util) {
@ -227,7 +227,7 @@ public class MechanicalSawScenes {
scene.world.destroyBlock(util.grid.at(1, 1, 2));
scene.world.hideSection(util.select.layersFrom(2)
.add(util.select.fromTo(2, 1, 2, 1, 1, 3)), Direction.UP);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.idle(15);
scene.world.setBlocks(util.select.fromTo(2, 1, 2, 1, 20, 3), Blocks.JUNGLE_LOG.defaultBlockState(), false);
scene.world.showSection(util.select.layersFrom(2)
@ -350,7 +350,7 @@ public class MechanicalSawScenes {
scene.idle(40);
scene.world.restoreBlocks(tree);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.world.glueBlockOnto(util.grid.at(5, 2, 2), Direction.DOWN, contraption);
scene.overlay.showText(60)

View file

@ -123,9 +123,9 @@ public class MovementActorScenes {
ElementLink<EntityElement> entity2 =
scene.world.createItemEntity(entitySpawn, util.vector.of(0, 0.2, 0), itemStack);
scene.idle(10);
scene.world.modifyEntity(entity1, Entity::remove);
scene.world.modifyEntity(entity1, Entity::discard);
scene.idle(10);
scene.world.modifyEntity(entity2, Entity::remove);
scene.world.modifyEntity(entity2, Entity::discard);
scene.overlay
.showControls(new InputWindowElement(util.vector.topOf(5, 3, 2), Pointing.DOWN).withItem(itemStack), 40);
@ -146,9 +146,9 @@ public class MovementActorScenes {
scene.world.createItemOnBelt(beltPos, Direction.EAST, itemStack);
scene.idle(20);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.idle(15);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.overlay.showText(120)
.placeNearTarget()
@ -282,7 +282,7 @@ public class MovementActorScenes {
scene.idle(101);
scene.world.hideSection(crops, Direction.DOWN);
scene.idle(15);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.world.setBlocks(crops, Blocks.WHEAT.defaultBlockState()
.setValue(CropBlock.AGE, 7), false);
scene.world.showSection(crops, Direction.UP);
@ -400,7 +400,7 @@ public class MovementActorScenes {
scene.world.hideSection(garbage, Direction.UP);
scene.idle(40);
scene.world.setBlocks(garbage, Blocks.SNOW.defaultBlockState(), false);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
ElementLink<WorldSectionElement> chest =
scene.world.showIndependentSection(util.select.position(4, 2, 2), Direction.DOWN);

View file

@ -92,7 +92,7 @@ public class ProcessingScenes {
ElementLink<EntityElement> entity1 =
scene.world.createItemEntity(entitySpawn, util.vector.of(0, 0.2, 0), itemStack);
scene.idle(18);
scene.world.modifyEntity(entity1, Entity::remove);
scene.world.modifyEntity(entity1, Entity::discard);
scene.world.modifyTileEntity(millstone, MillstoneTileEntity.class,
ms -> ms.inputInv.setStackInSlot(0, itemStack));
scene.idle(10);
@ -208,7 +208,7 @@ public class ProcessingScenes {
ElementLink<EntityElement> entity1 =
scene.world.createItemEntity(entitySpawn, util.vector.of(0, 0.2, 0), input);
scene.idle(18);
scene.world.modifyEntity(entity1, Entity::remove);
scene.world.modifyEntity(entity1, Entity::discard);
Emitter blockSpace =
Emitter.withinBlockSpace(new ItemParticleOption(ParticleTypes.ITEM, input), util.vector.of(0, 0, 0));
scene.effects.emitParticles(util.vector.centerOf(center)
@ -235,7 +235,7 @@ public class ProcessingScenes {
scene.idle(5);
scene.world.showSection(beltCog, Direction.UP);
scene.idle(5);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.world.showSection(bottomBelt, Direction.SOUTH);
scene.idle(5);
@ -581,7 +581,7 @@ public class ProcessingScenes {
.placeNearTarget();
scene.idle(50);
scene.world.modifyEntities(Blaze.class, Entity::remove);
scene.world.modifyEntities(Blaze.class, Entity::discard);
scene.idle(20);
scene.world.showSection(util.select.position(2, 1, 2), Direction.DOWN);

View file

@ -299,15 +299,15 @@ public class TunnelScenes {
scene.world.createItemEntity(spawn, m, item1);
scene.idle(12);
scene.world.createItemOnBelt(beltPos, Direction.UP, item1);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.world.createItemEntity(spawn, m, item2);
scene.idle(12);
scene.world.createItemOnBelt(beltPos, Direction.UP, item2);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.world.createItemEntity(spawn, m, item3);
scene.idle(12);
scene.world.createItemOnBelt(beltPos, Direction.UP, item3);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.idle(50);
scene.world.showSectionAndMerge(util.select.position(3, 5, 2), Direction.DOWN, newBelt);
@ -324,15 +324,15 @@ public class TunnelScenes {
scene.world.createItemEntity(spawn, m, item1);
scene.idle(12);
scene.world.createItemOnBelt(beltPos, Direction.EAST, item1);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.world.createItemEntity(spawn, m, item2);
scene.idle(12);
scene.world.createItemOnBelt(beltPos, Direction.EAST, item2);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.world.createItemEntity(spawn, m, item3);
scene.idle(12);
scene.world.createItemOnBelt(beltPos, Direction.EAST, item3);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.idle(30);
}

View file

@ -54,50 +54,6 @@ import net.minecraftforge.event.world.BlockEvent;
public class BlockHelper {
@OnlyIn(Dist.CLIENT)
public static void addReducedDestroyEffects(BlockState state, Level worldIn, BlockPos pos, ParticleEngine manager) {
if (!(worldIn instanceof ClientLevel))
return;
ClientLevel world = (ClientLevel) worldIn;
VoxelShape voxelshape = state.getShape(world, pos);
MutableInt amtBoxes = new MutableInt(0);
voxelshape.forAllBoxes((x1, y1, z1, x2, y2, z2) -> amtBoxes.increment());
double chance = 1d / amtBoxes.getValue();
if (state.isAir())
return;
if (RenderProperties.get(state)
.addDestroyEffects(state, worldIn, pos, manager))
return;
voxelshape.forAllBoxes((p_172273_, p_172274_, p_172275_, p_172276_, p_172277_, p_172278_) -> {
double d1 = Math.min(1.0D, p_172276_ - p_172273_);
double d2 = Math.min(1.0D, p_172277_ - p_172274_);
double d3 = Math.min(1.0D, p_172278_ - p_172275_);
int i = Math.max(2, Mth.ceil(d1 / 0.25D));
int j = Math.max(2, Mth.ceil(d2 / 0.25D));
int k = Math.max(2, Mth.ceil(d3 / 0.25D));
for (int l = 0; l < i; ++l) {
for (int i1 = 0; i1 < j; ++i1) {
for (int j1 = 0; j1 < k; ++j1) {
if (world.random.nextDouble() > chance)
continue;
double d4 = ((double) l + 0.5D) / (double) i;
double d5 = ((double) i1 + 0.5D) / (double) j;
double d6 = ((double) j1 + 0.5D) / (double) k;
double d7 = d4 * d1 + p_172273_;
double d8 = d5 * d2 + p_172274_;
double d9 = d6 * d3 + p_172275_;
manager.add(new TerrainParticle(world, pos.getX() + d7, pos.getY() + d8, pos.getZ() + d9,
d4 - 0.5D, d5 - 0.5D, d6 - 0.5D, state, pos).updateSprite(state, pos));
}
}
}
});
}
public static BlockState setZeroAge(BlockState blockState) {
if (blockState.hasProperty(BlockStateProperties.AGE_1))
return blockState.setValue(BlockStateProperties.AGE_1, 0);

View file

@ -0,0 +1,60 @@
package com.simibubi.create.foundation.utility;
import org.apache.commons.lang3.mutable.MutableInt;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.ParticleEngine;
import net.minecraft.client.particle.TerrainParticle;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.client.IBlockRenderProperties;
public class ReducedDestroyEffects implements IBlockRenderProperties {
@Override
public boolean addDestroyEffects(BlockState state, Level worldIn, BlockPos pos, ParticleEngine manager) {
if (!(worldIn instanceof ClientLevel))
return true;
ClientLevel world = (ClientLevel) worldIn;
VoxelShape voxelshape = state.getShape(world, pos);
MutableInt amtBoxes = new MutableInt(0);
voxelshape.forAllBoxes((x1, y1, z1, x2, y2, z2) -> amtBoxes.increment());
double chance = 1d / amtBoxes.getValue();
if (state.isAir())
return true;
voxelshape.forAllBoxes((p_172273_, p_172274_, p_172275_, p_172276_, p_172277_, p_172278_) -> {
double d1 = Math.min(1.0D, p_172276_ - p_172273_);
double d2 = Math.min(1.0D, p_172277_ - p_172274_);
double d3 = Math.min(1.0D, p_172278_ - p_172275_);
int i = Math.max(2, Mth.ceil(d1 / 0.25D));
int j = Math.max(2, Mth.ceil(d2 / 0.25D));
int k = Math.max(2, Mth.ceil(d3 / 0.25D));
for (int l = 0; l < i; ++l) {
for (int i1 = 0; i1 < j; ++i1) {
for (int j1 = 0; j1 < k; ++j1) {
if (world.random.nextDouble() > chance)
continue;
double d4 = ((double) l + 0.5D) / (double) i;
double d5 = ((double) i1 + 0.5D) / (double) j;
double d6 = ((double) j1 + 0.5D) / (double) k;
double d7 = d4 * d1 + p_172273_;
double d8 = d5 * d2 + p_172274_;
double d9 = d6 * d3 + p_172275_;
manager.add(new TerrainParticle(world, pos.getX() + d7, pos.getY() + d8, pos.getZ() + d9,
d4 - 0.5D, d5 - 0.5D, d6 - 0.5D, state, pos).updateSprite(state, pos));
}
}
}
});
return true;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB