Skip to content

Commit

Permalink
Merge remote-tracking branch 'bitbucket/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
X-com committed Dec 23, 2019
2 parents c63f488 + 7b24533 commit d6c1c8e
Show file tree
Hide file tree
Showing 19 changed files with 389 additions and 176 deletions.
4 changes: 2 additions & 2 deletions src/main/java/carpetclient/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import carpetclient.random.RandomtickDisplay;
import carpetclient.rules.TickRate;
import com.google.gson.*;
import javafx.geometry.BoundingBox;

import java.io.File;
import java.io.FileNotFoundException;
Expand All @@ -30,12 +29,13 @@ public class Config {
public static boolean missingTools = false;
public static boolean boundingBoxMarkers = false;
public static boolean villageMarkers = false;
public static int structureBlockLimit = 32;
// public static int structureBlockLimit = 32;
public static int pushLimit = 12;
public static float tickRate;
public static boolean playerCollisions = true;
public static boolean ignoreEntityWhenPlacing = false;
public static boolean movableTileEntities = false;
public static String pistonGhostBlocksFix;

public static ConfigBoolean setTickRate = new ConfigBoolean("Tick Rate", false, "Toggles if the client should slow the game down (Forge integrated clients might want to turn this off as the tick rate slowdown is not compatible with forge yet).");
public static ConfigBoolean bucketGhostBlockFix = new ConfigBoolean("Liquid ghost block fix", false, "Toggles the ghost block liquid option.");
Expand Down
132 changes: 0 additions & 132 deletions src/main/java/carpetclient/NewCrafting.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package carpetclient.mixinInterface;

public interface AMixinRegistryNamespaced {
public void clear();
}
14 changes: 14 additions & 0 deletions src/main/java/carpetclient/mixins/IMixinCraftingManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package carpetclient.mixins;

import net.minecraft.item.crafting.CraftingManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(CraftingManager.class)
public interface IMixinCraftingManager {

@Accessor("nextAvailableId")
static void setNextAvailableId(int i) {
throw new AssertionError("Mixin didn't patch me!");
}
}
22 changes: 22 additions & 0 deletions src/main/java/carpetclient/mixins/IMixinRecipeBookClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package carpetclient.mixins;

import net.minecraft.client.gui.recipebook.RecipeList;
import net.minecraft.client.util.RecipeBookClient;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(RecipeBookClient.class)
public interface IMixinRecipeBookClient {

@Invoker
static RecipeList callNewRecipeList(CreativeTabs srcTab) {
return null;
}

@Invoker
static CreativeTabs callGetItemStackTab(ItemStack stackIn) {
return null;
}
}
83 changes: 54 additions & 29 deletions src/main/java/carpetclient/mixins/MixinBlockPistonBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import carpetclient.Hotkeys;
import carpetclient.coders.EDDxample.PistonHelper;
import carpetclient.util.ITileEntityPiston;
import carpetclient.util.IWorldServer;
import com.google.common.collect.Lists;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDirectional;
Expand All @@ -26,10 +27,7 @@
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Surrogate;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
Expand All @@ -47,6 +45,8 @@ public abstract class MixinBlockPistonBase extends BlockDirectional {
private List<TileEntity> tileEntitiesList;

private BlockPos blockpos; // For movableTE

private int mixinEventParam; // For ghost blocks fix

@Shadow
private void checkForMove(World worldIn, BlockPos pos, IBlockState state) {
Expand Down Expand Up @@ -94,31 +94,6 @@ public void canPlaceOnOver(World worldIn, BlockPos pos, EnumFacing facing, float
cir.setReturnValue(this.getDefaultState().withProperty(FACING, facing).withProperty(EXTENDED, Boolean.valueOf(false)));
}

// ghost block fix
@Redirect(method = "eventReceived", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockPistonBase;doMove(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/EnumFacing;Z)Z", ordinal = 1))
public boolean eventReceivedMixins(BlockPistonBase obj,
World worldIn1, BlockPos pos1, EnumFacing enumfacing, boolean extending, // from doMove
IBlockState state, World worldIn2, BlockPos pos2, int id, int param // from eventReceived
) {
// adding the meta check here and make sure the client only grabs blocks if the block in front isn't
// a moving block on the server even if its regular blocks that can be pulled on the client. both client
// and server should behave the same by forcing the client to ignore blocks if the server can't pull the block in front.
if ((param & 16) == 0) {
return this.doMove(worldIn1, pos1, enumfacing, false);
}

return false;
}

// // ghost block fix
// @Redirect(method = "checkForMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addBlockEvent(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;II)V", ordinal = 1))
// public void eventReceivedMixins(World worldIn1,
// BlockPos pos1, Block blockIn, int eventID, int eventParam, // from addBlockEvent
// World worldIn2, BlockPos pos2, IBlockState state // from checkForMove
// ) {
// worldIn1.addBlockEvent(pos1, this, 1, eventParam | ignoreMovingBlockMeta(worldIn1, pos1, EnumFacing.byHorizontalIndex(eventParam)));
// }

/*
* This if statement checks if the the pulling block (block that is 2 blocks infront of the extended piston)
* is a non-moving block and returns a meta value of 16 so it can tell the client to ignore pulling blocks
Expand Down Expand Up @@ -262,4 +237,54 @@ private void setTileEntityTE(World worldIn, BlockPos pos, EnumFacing direction,
((ITileEntityPiston) e).setCarriedBlockEntity(tileEntitiesList.get(l));
}
// End MovableTE

@Redirect(method = "checkForMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addBlockEvent(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;II)V", ordinal = 1))
private void sendDropBlockFlag(World world, BlockPos pos, Block blockIn, int eventID, int eventParam, World worldIn, BlockPos callpos, IBlockState state)
{
int suppress_move = 0;

if (Config.pistonGhostBlocksFix.equals("clientAndServer"))
{
final EnumFacing enumfacing = state.getValue(FACING);

final BlockPos blockpos = new BlockPos(callpos).offset(enumfacing, 2);
final IBlockState iblockstate = worldIn.getBlockState(blockpos);

if (iblockstate.getBlock() == Blocks.PISTON_EXTENSION)
{
final TileEntity tileentity = worldIn.getTileEntity(blockpos);

if (tileentity instanceof TileEntityPiston)
{
final TileEntityPiston tileentitypiston = (TileEntityPiston) tileentity;
if (tileentitypiston.getFacing() == enumfacing && tileentitypiston.isExtending()
&& (((ITileEntityPiston) tileentitypiston).getLastProgress() < 0.5F
|| tileentitypiston.getWorld().getTotalWorldTime() == ((ITileEntityPiston) tileentitypiston).getLastTicked()
|| !((IWorldServer) worldIn).haveBlockActionsProcessed()))
{
suppress_move = 16;
}
}
}
}

worldIn.addBlockEvent(pos, blockIn, eventID, eventParam | suppress_move);
}

@Inject(method = "eventReceived", at = @At("HEAD"))
private void setEventParam(IBlockState state, World worldIn, BlockPos pos, int id, int param, CallbackInfoReturnable<Integer> cir)
{
this.mixinEventParam = param;
}

@ModifyVariable(method = "eventReceived", name = "flag1", index = 11, at = @At(value = "LOAD", ordinal = 0))
private boolean didServerDrop(boolean flag1)
{
if ((this.mixinEventParam & 16) == 16 && Config.pistonGhostBlocksFix.equals("clientAndServer"))
{
flag1 = true;
}

return flag1;
}
}
21 changes: 13 additions & 8 deletions src/main/java/carpetclient/mixins/MixinBootstrap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package carpetclient.mixins;

import java.io.IOException;
import java.lang.reflect.Method;

import org.apache.logging.log4j.LogManager;
Expand All @@ -8,7 +9,6 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import carpetclient.NewCrafting;
import net.minecraft.init.Bootstrap;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
Expand All @@ -17,13 +17,19 @@
public class MixinBootstrap {

@Inject(method = "register", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/crafting/CraftingManager;init()Z", shift = At.Shift.AFTER))
private static void addExtraCraftingRecipes(CallbackInfo ci) {
NewCrafting.createRockets();
registerRecipe("rocket1", NewCrafting.rocketOne);
registerRecipe("rocket2", NewCrafting.rocketTwo);
registerRecipe("rocket3", NewCrafting.rocketThree);
private static void addExtraCraftingRecipes(CallbackInfo ci) throws IOException {
// CustomCrafting.createRockets();
// registerRecipe("rocket1", CustomCrafting.rocketOne);
// registerRecipe("rocket2", CustomCrafting.rocketTwo);
// registerRecipe("rocket3", CustomCrafting.rocketThree);
// CustomCrafting.registerCustomRecipes();

// for (ResourceLocation irecipe : CraftingManager.REGISTRY.getKeys())
// {
// System.out.println(irecipe);
// }
}

private static void registerRecipe(String name, IRecipe recipe) {
try {
CraftingManager.register(name, recipe);
Expand All @@ -38,5 +44,4 @@ private static void registerRecipe(String name, IRecipe recipe) {
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package carpetclient.mixins;

import net.minecraft.network.NettyCompressionDecoder;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(NettyCompressionDecoder.class)
public class MixinNettyCompressionDecoder {
@ModifyConstant(method = "decode", constant = @Constant(intValue = 2097152), remap = false)
private static int limitExpander(int timeoutSeconds) {
return Integer.MAX_VALUE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package carpetclient.mixins;

import net.minecraft.network.NettyVarint21FrameDecoder;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(NettyVarint21FrameDecoder.class)
public class MixinNettyVarint21FrameDecoder {
@ModifyConstant(method = "decode", constant = @Constant(intValue = 3), remap = false)
private static int limitExpander(int timeoutSeconds) {
return 5;
}
}
Loading

0 comments on commit d6c1c8e

Please sign in to comment.