From 4d169616365e9066d2c3171eaae1f40927f01982 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Sat, 11 Apr 2020 00:55:51 +0200 Subject: [PATCH] Bug Fixes - Sandpaper can no longer repair tools - Fixed players getting kicked for "flying" when moved by contraptions or fans - Saw no longer duplicates itself when broken in an overstressed state - Belts can no longer pass items on to a vertical belt --- build.gradle | 1 + .../simibubi/create/config/CCuriosities.java | 2 - .../contraptions/ContraptionCollider.java | 4 ++ .../components/fan/AirCurrent.java | 4 ++ .../contraptions/components/saw/SawBlock.java | 2 +- .../components/saw/SawTileEntity.java | 6 ++- .../relays/belt/transport/BeltInventory.java | 2 +- .../curiosities/tools/SandPaperItem.java | 3 +- .../tools/SandPaperPolishingRecipe.java | 42 +------------------ .../resources/META-INF/accesstransformer.cfg | 1 + .../resources/assets/create/lang/en_us.json | 4 +- 11 files changed, 20 insertions(+), 51 deletions(-) create mode 100644 src/main/resources/META-INF/accesstransformer.cfg diff --git a/build.gradle b/build.gradle index 5f1c00098..3b85fffed 100644 --- a/build.gradle +++ b/build.gradle @@ -21,6 +21,7 @@ sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = co minecraft { mappings channel: 'snapshot', version: '20200119-1.14.3' + accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') runs { client { diff --git a/src/main/java/com/simibubi/create/config/CCuriosities.java b/src/main/java/com/simibubi/create/config/CCuriosities.java index a4d4ebea5..4b23a4f05 100644 --- a/src/main/java/com/simibubi/create/config/CCuriosities.java +++ b/src/main/java/com/simibubi/create/config/CCuriosities.java @@ -11,7 +11,6 @@ public class CCuriosities extends ConfigBase { public ConfigBool enableRefinedRadianceRecipe = b(true, "enableRefinedRadianceRecipe", Comments.refinedRadianceRecipe); public ConfigBool enableShadowSteelRecipe = b(true, "enableShadowSteelRecipe", Comments.shadowSteelRecipe); - public ConfigBool enableSandPaperToolPolishing = b(true, "enableSandPaperToolPolishing", Comments.sandPaperOnTools); public ConfigFloat cocoaLogGrowthSpeed = f(20, 0, 100, "cocoaLogGrowthSpeed", Comments.cocoa); @Override @@ -24,7 +23,6 @@ public class CCuriosities extends ConfigBase { static String refinedRadiance = "The amount of Light sources destroyed before Chromatic Compound turns into Refined Radiance."; static String refinedRadianceRecipe = "Allow the standard Refined Radiance recipes."; static String shadowSteelRecipe = "Allow the standard Shadow Steel recipe."; - static String sandPaperOnTools = "Enable the tool repairing mechanic involving sand paper."; static String windowsInBlocks = "Allow Glass Panes to be put inside Blocks like Stairs, Slabs, Fences etc."; static String cocoa = "% of random Ticks causing a Cocoa log to grow."; static String zapperUndoLogLength = "The maximum amount of operations, a blockzapper can remember for undoing. (0 to disable undo)"; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/ContraptionCollider.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/ContraptionCollider.java index 9e1efeaeb..42d73959d 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/ContraptionCollider.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/ContraptionCollider.java @@ -14,6 +14,7 @@ import net.minecraft.entity.EntityType; import net.minecraft.entity.IProjectile; import net.minecraft.entity.MoverType; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.AxisDirection; @@ -73,6 +74,7 @@ public class ContraptionCollider { if (allowedMovement.equals(relativeMotion)) continue; + if (allowedMovement.y != relativeMotion.y) { entity.fall(entity.fallDistance, 1); entity.fallDistance = 0; @@ -80,6 +82,8 @@ public class ContraptionCollider { DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> checkForClientPlayerCollision(entity)); } + if (entity instanceof ServerPlayerEntity) + ((ServerPlayerEntity) entity).connection.floatingTickCount = 0; if (entity instanceof PlayerEntity && !world.isRemote) return; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/fan/AirCurrent.java b/src/main/java/com/simibubi/create/modules/contraptions/components/fan/AirCurrent.java index 1522ad3e9..7d472a462 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/fan/AirCurrent.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/fan/AirCurrent.java @@ -18,6 +18,7 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.Entity; import net.minecraft.entity.item.ItemEntity; +import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.nbt.CompoundNBT; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; @@ -95,6 +96,9 @@ public class AirCurrent { entity.setMotion(previousMotion.add(new Vec3d(xIn, yIn, zIn).scale(1 / 8f))); entity.fallDistance = 0; + if (entity instanceof ServerPlayerEntity) + ((ServerPlayerEntity) entity).connection.floatingTickCount = 0; + if (InWorldProcessing.isFrozen()) return; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawBlock.java index 1cb3b50e6..1de31a45c 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawBlock.java @@ -135,7 +135,7 @@ public class SawBlock extends DirectionalAxisKineticBlock implements ITE ItemHelper.dropContents(worldIn, pos, te.inventory)); TileEntityBehaviour.destroy(worldIn, pos, FilteringBehaviour.TYPE); - worldIn.removeTileEntity(pos); + worldIn.removeTileEntity(pos); } @Override diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawTileEntity.java index 2f16da19c..fb695c9f8 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawTileEntity.java @@ -55,6 +55,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { private int recipeIndex; private LazyOptional invProvider = LazyOptional.empty(); private FilteringBehaviour filtering; + private boolean destroyed; public SawTileEntity() { super(AllTileEntities.SAW.type); @@ -81,7 +82,7 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { super.onSpeedChanged(prevSpeed); boolean shouldRun = Math.abs(getSpeed()) > 1 / 64f; boolean running = getBlockState().get(RUNNING); - if (shouldRun != running) + if (shouldRun != running && !destroyed) world.setBlockState(pos, getBlockState().with(RUNNING, shouldRun), 2 | 16); } @@ -212,8 +213,9 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { @Override public void remove() { - super.remove(); invProvider.invalidate(); + destroyed = true; + super.remove(); } @Override diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/transport/BeltInventory.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/transport/BeltInventory.java index ff56a36f9..abf85f488 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/transport/BeltInventory.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/transport/BeltInventory.java @@ -245,7 +245,7 @@ public class BeltInventory { } // next block is not a belt - if (!AllBlocks.BELT.typeOf(state)) { + if (!AllBlocks.BELT.typeOf(state) || state.get(BeltBlock.SLOPE) == Slope.VERTICAL) { if (!Block.hasSolidSide(state, world, nextPosition, movementFacing.getOpposite())) { eject(current); iterator.remove(); diff --git a/src/main/java/com/simibubi/create/modules/curiosities/tools/SandPaperItem.java b/src/main/java/com/simibubi/create/modules/curiosities/tools/SandPaperItem.java index d50bd5948..b80f3c34b 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/tools/SandPaperItem.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/tools/SandPaperItem.java @@ -9,7 +9,6 @@ import com.simibubi.create.modules.curiosities.tools.SandPaperItemRenderer.SandP import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.player.PlayerEntity; @@ -111,7 +110,7 @@ public class SandPaperItem extends Item implements IHaveCustomItemModel { @Override public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { - return enchantment == Enchantments.FORTUNE || super.canApplyAtEnchantingTable(stack, enchantment); + return super.canApplyAtEnchantingTable(stack, enchantment); } @Override diff --git a/src/main/java/com/simibubi/create/modules/curiosities/tools/SandPaperPolishingRecipe.java b/src/main/java/com/simibubi/create/modules/curiosities/tools/SandPaperPolishingRecipe.java index d4cf72eb3..af430fff7 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/tools/SandPaperPolishingRecipe.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/tools/SandPaperPolishingRecipe.java @@ -1,25 +1,18 @@ package com.simibubi.create.modules.curiosities.tools; -import java.util.ArrayList; import java.util.List; -import java.util.Map; import com.simibubi.create.AllRecipes; -import com.simibubi.create.config.AllConfigs; import com.simibubi.create.modules.contraptions.processing.ProcessingIngredient; import com.simibubi.create.modules.contraptions.processing.ProcessingOutput; import com.simibubi.create.modules.contraptions.processing.ProcessingRecipe; import com.simibubi.create.modules.curiosities.tools.SandPaperPolishingRecipe.SandPaperInv; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.DamageSource; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.Explosion.Mode; import net.minecraft.world.World; import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.wrapper.RecipeWrapper; @@ -34,46 +27,13 @@ public class SandPaperPolishingRecipe extends ProcessingRecipe { } public static boolean canPolish(World world, ItemStack stack) { - return (stack.isDamageable() && isPolishingEnabled()) || !getMatchingRecipes(world, stack).isEmpty(); - } - - public static Boolean isPolishingEnabled() { - return AllConfigs.SERVER.curiosities.enableSandPaperToolPolishing.get(); + return !getMatchingRecipes(world, stack).isEmpty(); } public static ItemStack applyPolish(World world, Vec3d position, ItemStack stack, ItemStack sandPaperStack) { List> matchingRecipes = getMatchingRecipes(world, stack); if (!matchingRecipes.isEmpty()) return matchingRecipes.get(0).getCraftingResult(new SandPaperInv(stack)).copy(); - if (stack.isDamageable() && isPolishingEnabled()) { - - stack.setDamage(stack.getDamage() / 2); - - int fortuneLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, sandPaperStack); - float chanceToPunish = (float) (1 / Math.pow(2, fortuneLevel + 1)); - - if (world.rand.nextFloat() > chanceToPunish) - return stack; - - if (stack.isEnchanted()) { - Map enchantments = EnchantmentHelper.getEnchantments(stack); - ArrayList list = new ArrayList<>(enchantments.keySet()); - Enchantment randomKey = list.get(world.rand.nextInt(list.size())); - int level = enchantments.get(randomKey); - if (level <= 1) - enchantments.remove(randomKey); - else - enchantments.put(randomKey, level - 1); - EnchantmentHelper.setEnchantments(enchantments, stack); - if (randomKey.isCurse()) - if (!world.isRemote) - world.createExplosion(null, CURSED_POLISHING, position.x, position.y, position.z, 2, true, - Mode.DESTROY); - } else { - stack = ItemStack.EMPTY; - } - } - return stack; } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg new file mode 100644 index 000000000..02bc0b9d4 --- /dev/null +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -0,0 +1 @@ +public net.minecraft.network.play.ServerPlayNetHandler field_147365_f # floatingTickCount \ No newline at end of file diff --git a/src/main/resources/assets/create/lang/en_us.json b/src/main/resources/assets/create/lang/en_us.json index 290ce4c0b..06d09ad10 100644 --- a/src/main/resources/assets/create/lang/en_us.json +++ b/src/main/resources/assets/create/lang/en_us.json @@ -943,7 +943,7 @@ "block.create.clockwork_bearing.tooltip": "CLOCKWORK BEARING", "block.create.clockwork_bearing.tooltip.summary": "An advanced version of the _Mechanical_ _Bearing_ for rotating up to two _clock_ _hands_ according to current _in-game_ _time_.", "block.create.clockwork_bearing.tooltip.condition1": "When Rotated", - "block.create.clockwork_bearing.tooltip.behaviour1": "Starts rotating the attached Structure towards the _current_ _hour_. If a second structure is present, it will serve as the _minute_ _hand_.", + "block.create.clockwork_bearing.tooltip.behaviour1": "Starts rotating the attached Structure towards the _current_ _hour_. If an independent second structure exists in front of the first one, it will serve as the _minute_ _hand_.", "block.create.sequenced_gearshift.tooltip": "SEQUENCED GEARSHIFT", "block.create.sequenced_gearshift.tooltip.summary": "A _programmable_ _utility_ _component,_ which can change its _rotational_ _through-put_ according to up to _5_ _consecutive_ _instructions._ Use this to power Mechanical Bearings, Pistons or Pulleys with more control over timing and speed. May become less precise at higher speeds.", @@ -1131,7 +1131,7 @@ "block.create.stress_gauge.tooltip.behaviour1": "Indicates a color corresponding to the level of stress. _Over-stressed_ _networks_ will cease to move. Stress can be relieved by adding more _rotational_ _sources_ to the network.", "tool.create.sand_paper.tooltip": "SAND PAPER", - "tool.create.sand_paper.tooltip.summary": "A rough paper that can be used to _polish_ _materials_ or sharpen your _tools_.", + "tool.create.sand_paper.tooltip.summary": "A rough paper that can be used to _polish_ _materials_. Can be automatically applied using the Deployer.", "tool.create.sand_paper.tooltip.condition1": "When Used", "tool.create.sand_paper.tooltip.behaviour1": "Applies polish to items held in the _offhand_ or lying on the _floor_ when _looking_ _at_ _them_",