mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-10 20:11:35 +01:00
Midnight bugs
- Fixed deployers not firing any right-click actions - Fixed basin renderer crashing outside of dev env - Fixed some lighting and flickering on psis
This commit is contained in:
parent
6e285e2f8b
commit
5c56adaeaa
6 changed files with 78 additions and 25 deletions
|
@ -33,7 +33,7 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<Por
|
||||||
BlockState blockState = te.getBlockState();
|
BlockState blockState = te.getBlockState();
|
||||||
float progress = te.getExtensionDistance(partialTicks);
|
float progress = te.getExtensionDistance(partialTicks);
|
||||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||||
render(blockState, progress, te.isConnected(), sbb -> sbb.renderInto(ms, vb), ms);
|
render(blockState, progress, te.isConnected(), sbb -> sbb.light(light).renderInto(ms, vb), ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
|
public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class PortableStorageInterfaceTileEntity extends SmartTileEntity {
|
||||||
|
|
||||||
boolean isConnected() {
|
boolean isConnected() {
|
||||||
int timeUnit = getTransferTimeout() / 2;
|
int timeUnit = getTransferTimeout() / 2;
|
||||||
return transferTimer >= timeUnit && transferTimer < timeUnit * 3;
|
return transferTimer >= timeUnit && transferTimer <= timeUnit * 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getExtensionDistance(float partialTicks) {
|
float getExtensionDistance(float partialTicks) {
|
||||||
|
|
|
@ -6,16 +6,6 @@ import static net.minecraftforge.eventbus.api.Event.Result.DENY;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.advancements.CriteriaTriggers;
|
|
||||||
import net.minecraft.block.BeehiveBlock;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
|
||||||
import net.minecraft.enchantment.Enchantments;
|
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
|
||||||
import net.minecraft.server.management.PlayerInteractionManager;
|
|
||||||
import net.minecraft.stats.Stats;
|
|
||||||
import net.minecraft.tileentity.BeehiveTileEntity;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
@ -23,14 +13,20 @@ import com.simibubi.create.content.contraptions.components.deployer.DeployerTile
|
||||||
import com.simibubi.create.content.curiosities.tools.SandPaperItem;
|
import com.simibubi.create.content.curiosities.tools.SandPaperItem;
|
||||||
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
|
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
|
||||||
|
|
||||||
|
import net.minecraft.advancements.CriteriaTriggers;
|
||||||
|
import net.minecraft.block.BeehiveBlock;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
|
import net.minecraft.enchantment.Enchantments;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.fluid.Fluid;
|
import net.minecraft.fluid.Fluid;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.inventory.EquipmentSlotType;
|
import net.minecraft.inventory.EquipmentSlotType;
|
||||||
|
@ -43,6 +39,10 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.ItemUseContext;
|
import net.minecraft.item.ItemUseContext;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.server.management.PlayerInteractionManager;
|
||||||
|
import net.minecraft.stats.Stats;
|
||||||
|
import net.minecraft.tileentity.BeehiveTileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
@ -95,7 +95,8 @@ public class DeployerHandler {
|
||||||
|
|
||||||
static boolean shouldActivate(ItemStack held, World world, BlockPos targetPos) {
|
static boolean shouldActivate(ItemStack held, World world, BlockPos targetPos) {
|
||||||
if (held.getItem() instanceof BlockItem)
|
if (held.getItem() instanceof BlockItem)
|
||||||
if (world.getBlockState(targetPos).getBlock() == ((BlockItem) held.getItem()).getBlock())
|
if (world.getBlockState(targetPos)
|
||||||
|
.getBlock() == ((BlockItem) held.getItem()).getBlock())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (held.getItem() instanceof BucketItem) {
|
if (held.getItem() instanceof BucketItem) {
|
||||||
|
@ -155,7 +156,8 @@ public class DeployerHandler {
|
||||||
}
|
}
|
||||||
if (!success && stack.isFood() && entity instanceof PlayerEntity) {
|
if (!success && stack.isFood() && entity instanceof PlayerEntity) {
|
||||||
PlayerEntity playerEntity = (PlayerEntity) entity;
|
PlayerEntity playerEntity = (PlayerEntity) entity;
|
||||||
if (playerEntity.canEat(item.getFood().canEatWhenFull())) {
|
if (playerEntity.canEat(item.getFood()
|
||||||
|
.canEatWhenFull())) {
|
||||||
playerEntity.onFoodEaten(world, stack);
|
playerEntity.onFoodEaten(world, stack);
|
||||||
player.spawnedItemEffects = stack.copy();
|
player.spawnedItemEffects = stack.copy();
|
||||||
success = true;
|
success = true;
|
||||||
|
@ -254,8 +256,11 @@ public class DeployerHandler {
|
||||||
boolean flag1 =
|
boolean flag1 =
|
||||||
!(player.isSneaking() && holdingSomething) || (stack.doesSneakBypassUse(world, clickedPos, player));
|
!(player.isSneaking() && holdingSomething) || (stack.doesSneakBypassUse(world, clickedPos, player));
|
||||||
|
|
||||||
|
if (clickedState.getBlock() instanceof BeehiveBlock)
|
||||||
|
return; // Beehives assume a lot about the usage context. Crashes to side-effects
|
||||||
|
|
||||||
// Use on block
|
// Use on block
|
||||||
if (useBlock != DENY && flag1 && clickedState.getBlock() instanceof BeehiveBlock && clickedState.onUse(world, player, hand, result) == ActionResultType.SUCCESS)
|
if (useBlock != DENY && flag1 && clickedState.onUse(world, player, hand, result) == ActionResultType.SUCCESS)
|
||||||
return;
|
return;
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -304,7 +309,7 @@ public class DeployerHandler {
|
||||||
|
|
||||||
private static boolean safeTryHarvestBlock(PlayerInteractionManager interactionManager, BlockPos clickedPos) {
|
private static boolean safeTryHarvestBlock(PlayerInteractionManager interactionManager, BlockPos clickedPos) {
|
||||||
BlockState state = interactionManager.world.getBlockState(clickedPos);
|
BlockState state = interactionManager.world.getBlockState(clickedPos);
|
||||||
if(!(state.getBlock() instanceof BeehiveBlock))
|
if (!(state.getBlock() instanceof BeehiveBlock))
|
||||||
return interactionManager.tryHarvestBlock(clickedPos);
|
return interactionManager.tryHarvestBlock(clickedPos);
|
||||||
else {
|
else {
|
||||||
harvestBeehive(interactionManager, state, clickedPos);
|
harvestBeehive(interactionManager, state, clickedPos);
|
||||||
|
@ -312,19 +317,24 @@ public class DeployerHandler {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void harvestBeehive(PlayerInteractionManager interactionManager, BlockState state, BlockPos clickedPos) {
|
private static void harvestBeehive(PlayerInteractionManager interactionManager, BlockState state,
|
||||||
// Modified code from PlayerInteractionManager, Block and BeehiveBlock to handle deployers breaking beehives without crash.
|
BlockPos clickedPos) {
|
||||||
|
// Modified code from PlayerInteractionManager, Block and BeehiveBlock to handle
|
||||||
|
// deployers breaking beehives without crash.
|
||||||
ItemStack itemstack = interactionManager.player.getHeldItemMainhand();
|
ItemStack itemstack = interactionManager.player.getHeldItemMainhand();
|
||||||
ItemStack itemstack1 = itemstack.copy();
|
ItemStack itemstack1 = itemstack.copy();
|
||||||
|
|
||||||
boolean flag1 = state.canHarvestBlock(interactionManager.world, clickedPos, interactionManager.player);
|
boolean flag1 = state.canHarvestBlock(interactionManager.world, clickedPos, interactionManager.player);
|
||||||
itemstack.onBlockDestroyed(interactionManager.world, state, clickedPos, interactionManager.player);
|
itemstack.onBlockDestroyed(interactionManager.world, state, clickedPos, interactionManager.player);
|
||||||
if (itemstack.isEmpty() && !itemstack1.isEmpty())
|
if (itemstack.isEmpty() && !itemstack1.isEmpty())
|
||||||
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(interactionManager.player, itemstack1, Hand.MAIN_HAND);
|
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(interactionManager.player, itemstack1,
|
||||||
|
Hand.MAIN_HAND);
|
||||||
|
|
||||||
boolean flag = state.removedByPlayer(interactionManager.world, clickedPos, interactionManager.player, flag1, interactionManager.world.getFluidState(clickedPos));
|
boolean flag = state.removedByPlayer(interactionManager.world, clickedPos, interactionManager.player, flag1,
|
||||||
|
interactionManager.world.getFluidState(clickedPos));
|
||||||
if (flag)
|
if (flag)
|
||||||
state.getBlock().onPlayerDestroy(interactionManager.world, clickedPos, state);
|
state.getBlock()
|
||||||
|
.onPlayerDestroy(interactionManager.world, clickedPos, state);
|
||||||
|
|
||||||
if (flag && flag1) {
|
if (flag && flag1) {
|
||||||
interactionManager.player.addStat(Stats.BLOCK_MINED.get(state.getBlock()));
|
interactionManager.player.addStat(Stats.BLOCK_MINED.get(state.getBlock()));
|
||||||
|
@ -334,12 +344,13 @@ public class DeployerHandler {
|
||||||
Block.spawnDrops(state, interactionManager.world, clickedPos, te, interactionManager.player, heldItem);
|
Block.spawnDrops(state, interactionManager.world, clickedPos, te, interactionManager.player, heldItem);
|
||||||
|
|
||||||
if (!interactionManager.world.isRemote && te instanceof BeehiveTileEntity) {
|
if (!interactionManager.world.isRemote && te instanceof BeehiveTileEntity) {
|
||||||
BeehiveTileEntity beehivetileentity = (BeehiveTileEntity)te;
|
BeehiveTileEntity beehivetileentity = (BeehiveTileEntity) te;
|
||||||
if (EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, heldItem) == 0) {
|
if (EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, heldItem) == 0) {
|
||||||
interactionManager.world.updateComparatorOutputLevel(clickedPos, state.getBlock());
|
interactionManager.world.updateComparatorOutputLevel(clickedPos, state.getBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
CriteriaTriggers.BEE_NEST_DESTROYED.test((ServerPlayerEntity)interactionManager.player, state.getBlock(), heldItem, beehivetileentity.getBeeCount());
|
CriteriaTriggers.BEE_NEST_DESTROYED.test((ServerPlayerEntity) interactionManager.player,
|
||||||
|
state.getBlock(), heldItem, beehivetileentity.getBeeCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,11 @@ package com.simibubi.create.content.contraptions.components.structureMovement.tr
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.simibubi.create.CreateClient;
|
import com.simibubi.create.CreateClient;
|
||||||
|
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionEntity;
|
||||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||||
import com.simibubi.create.foundation.utility.Couple;
|
import com.simibubi.create.foundation.utility.Couple;
|
||||||
import com.simibubi.create.foundation.utility.Iterate;
|
import com.simibubi.create.foundation.utility.Iterate;
|
||||||
|
@ -55,6 +57,8 @@ public class MinecartTrain {
|
||||||
// SOFT collision - modify motion of carts with stressed links @t+1
|
// SOFT collision - modify motion of carts with stressed links @t+1
|
||||||
double sharedMotion = 0;
|
double sharedMotion = 0;
|
||||||
int participants = 0;
|
int participants = 0;
|
||||||
|
boolean stall = false;
|
||||||
|
|
||||||
for (int i = 0; i < couplings.size(); i++) {
|
for (int i = 0; i < couplings.size(); i++) {
|
||||||
MinecartCoupling minecartCoupling = couplings.get(i);
|
MinecartCoupling minecartCoupling = couplings.get(i);
|
||||||
boolean last = i + 1 == couplings.size();
|
boolean last = i + 1 == couplings.size();
|
||||||
|
@ -64,6 +68,14 @@ public class MinecartTrain {
|
||||||
sharedMotion += minecartCoupling.mainCart.get()
|
sharedMotion += minecartCoupling.mainCart.get()
|
||||||
.getMotion()
|
.getMotion()
|
||||||
.length();
|
.length();
|
||||||
|
|
||||||
|
List<Entity> passengers = minecartCoupling.mainCart.get().getPassengers();
|
||||||
|
if (!passengers.isEmpty() && passengers.get(0) instanceof ContraptionEntity)
|
||||||
|
if (((ContraptionEntity) passengers.get(0)).isStalled()) {
|
||||||
|
stall = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (last) {
|
if (last) {
|
||||||
participants++;
|
participants++;
|
||||||
|
@ -137,6 +149,12 @@ public class MinecartTrain {
|
||||||
MinecartCoupling minecartCoupling = couplings.get(i);
|
MinecartCoupling minecartCoupling = couplings.get(i);
|
||||||
if (!minecartCoupling.areBothEndsPresent())
|
if (!minecartCoupling.areBothEndsPresent())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (stall) {
|
||||||
|
minecartCoupling.asCouple().forEach(ame -> ame.setMotion(Vec3d.ZERO));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
double stress = getStressOfCoupling(minecartCoupling);
|
double stress = getStressOfCoupling(minecartCoupling);
|
||||||
if (stress > maxStress) {
|
if (stress > maxStress) {
|
||||||
maxStress = stress;
|
maxStress = stress;
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.simibubi.create.foundation.item;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
|
||||||
|
interface IItemHandlerModifiableIntermediate extends IItemHandlerModifiable {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public default ItemStack getStackInSlot(int slot) {
|
||||||
|
return getStackInSlotIntermediate(slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getStackInSlotIntermediate(int slot);
|
||||||
|
|
||||||
|
}
|
|
@ -7,11 +7,10 @@ import com.simibubi.create.foundation.tileEntity.SyncedTileEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraftforge.common.util.INBTSerializable;
|
import net.minecraftforge.common.util.INBTSerializable;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||||
|
|
||||||
public class SmartInventory extends RecipeWrapper implements IItemHandlerModifiable, INBTSerializable<CompoundNBT> {
|
public class SmartInventory extends RecipeWrapper implements IItemHandlerModifiableIntermediate, INBTSerializable<CompoundNBT> {
|
||||||
|
|
||||||
private boolean extractionAllowed;
|
private boolean extractionAllowed;
|
||||||
private boolean insertionAllowed;
|
private boolean insertionAllowed;
|
||||||
|
@ -83,6 +82,11 @@ public class SmartInventory extends RecipeWrapper implements IItemHandlerModifia
|
||||||
inv.setStackInSlot(slot, stack);
|
inv.setStackInSlot(slot, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackInSlot(int slot) {
|
||||||
|
return super.getStackInSlot(slot);
|
||||||
|
}
|
||||||
|
|
||||||
public int getStackLimit(int slot, @Nonnull ItemStack stack) {
|
public int getStackLimit(int slot, @Nonnull ItemStack stack) {
|
||||||
return Math.min(getSlotLimit(slot), stack.getMaxStackSize());
|
return Math.min(getSlotLimit(slot), stack.getMaxStackSize());
|
||||||
}
|
}
|
||||||
|
@ -118,4 +122,9 @@ public class SmartInventory extends RecipeWrapper implements IItemHandlerModifia
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackInSlotIntermediate(int slot) {
|
||||||
|
return getStackInSlot(slot);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue