Skip to content

Commit

Permalink
Bouncy
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubyboat1207 committed Jun 7, 2022
1 parent 779d4c3 commit 98624c8
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 17 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ minecraft_version=1.18.2
yarn_mappings=1.18.2+build.2
loader_version=0.13.3
# Mod Properties
mod_version=1.3.1
mod_version=1.3.2
maven_group=rubyboat
archives_base_name=ghost
# Dependencies
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/rubyboat/ghost/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
import java.util.Arrays;

public class Config {
/*
Challenge Ideas:
Minecraft but only chunks I have been on render
Minecraft but only one block renders at a time
Notes:
BlockRenderManager Exists
*/


static String block = "diamond_block";
static String camera_type = "";
static int camera_distance = 10;
Expand All @@ -28,6 +38,7 @@ public class Config {
static boolean is_cyrus_mode = true;
static boolean inNetherPortalEffect = false;
static boolean bouncy = false;
static boolean antfarm = false;
static String inPowderSnowEffect = "none";
static Integer fog = 000000;
static String title = "Minecraft";
Expand Down Expand Up @@ -113,6 +124,7 @@ public static boolean getBouncy()
public static boolean isRender_legs(){return getConfig().render_legs;}
public static boolean isRender_body(){return getConfig().render_body;}
public static boolean isRender_head(){return getConfig().render_head;}
public static boolean isAntfarm(){return getConfig().antfarm;}
public static float getModelOffset(){return getConfig().model_offset;}
public static String title(){return getConfig().title;}
public static Integer color(){return getConfig().biomecolor;}
Expand Down Expand Up @@ -199,6 +211,7 @@ public static ConfigBuilder MakeConfig()
ConfigCategory texture = builder.getOrCreateCategory(new TranslatableText("config_category.ghost.texture"));
ConfigCategory biome = builder.getOrCreateCategory(new TranslatableText("config_category.ghost.biome"));
ConfigCategory time = builder.getOrCreateCategory(new TranslatableText("config_category.ghost.time"));
ConfigCategory gamemodes = builder.getOrCreateCategory(new TranslatableText("config_category.ghost.gamemodes"));
ConfigEntryBuilder entryBuilder = builder.entryBuilder();
//---ENTRIES
DropdownMenuBuilder<String> blockmenu = entryBuilder.startStringDropdownMenu(new TranslatableText("entry.ghost.ghost_block"), Config.block)
Expand All @@ -218,7 +231,7 @@ public static ConfigBuilder MakeConfig()
.setSaveConsumer(newValue -> Config.weather = newValue
);
general.addEntry(blockmenu.build());
experimental.addEntry(cameramenu.build());
gamemodes.addEntry(cameramenu.build());
if(camera_type.equalsIgnoreCase("topdown"))
{
experimental.addEntry(entryBuilder.startIntSlider(new TranslatableText("entry.ghost.camera_distance"), Config.camera_distance, 0, 100).setSaveConsumer(newValue -> Config.camera_distance = newValue).build());
Expand Down Expand Up @@ -265,6 +278,10 @@ public static ConfigBuilder MakeConfig()
.setSaveConsumer(newValue -> Config.render_legs = newValue)
.build()
);
gamemodes.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("entry.ghost.AntFarm"), Config.antfarm)
.setSaveConsumer(newValue -> Config.antfarm = newValue)
.build()
);
texture.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("entry.ghost.render_body"), Config.render_body)
.setSaveConsumer(newValue -> Config.render_body = newValue)
.build()
Expand Down Expand Up @@ -330,6 +347,7 @@ public static class SerializedConfig
public boolean render_body;
public boolean render_head;
public boolean bouncy;
public boolean antfarm;
public float model_offset;
public Integer water;
public Integer waterfog;
Expand Down Expand Up @@ -363,6 +381,7 @@ public SerializedConfig()
this.water = Config.water;
this.waterfog = Config.waterfog;
this.bouncy = Config.bouncy;
this.antfarm = Config.antfarm;

}
public String serialized(){
Expand Down
15 changes: 5 additions & 10 deletions src/main/java/rubyboat/ghost/mixin/CameraMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.*;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -61,12 +58,12 @@ public void update(BlockView area, Entity focusedEntity, boolean thirdPerson, bo
{
if(!Config.getCamera_type().equalsIgnoreCase("choppy"))
{
this.setRotation(focusedEntity.getYaw(tickDelta), focusedEntity.getPitch(tickDelta));
this.setPos(MathHelper.lerp((double)tickDelta, focusedEntity.prevX, focusedEntity.getX()), MathHelper.lerp((double)tickDelta, focusedEntity.prevY, focusedEntity.getY()) + (double)MathHelper.lerp(tickDelta, this.lastCameraY, this.cameraY), MathHelper.lerp((double)tickDelta, focusedEntity.prevZ, focusedEntity.getZ()));
this.setRotation(Config.isAntfarm() ? 90 : focusedEntity.getYaw(tickDelta), Config.isAntfarm() ? 0 : focusedEntity.getPitch(tickDelta));
this.setPos(MathHelper.lerp((double)tickDelta, Config.isAntfarm() ? focusedEntity.getX() + 3 : focusedEntity.prevX, Config.isAntfarm() ? focusedEntity.getX() + 3 : focusedEntity.getX()), MathHelper.lerp((double)tickDelta, focusedEntity.prevY, focusedEntity.getY()) + (double)MathHelper.lerp(tickDelta, this.lastCameraY, this.cameraY), MathHelper.lerp((double)tickDelta, focusedEntity.prevZ, focusedEntity.getZ()));
}else
{
this.setRotation(focusedEntity.getYaw(), focusedEntity.getPitch());
this.setPos(focusedEntity.getX(), focusedEntity.prevY + this.cameraY, focusedEntity.getZ());
this.setRotation(Config.isAntfarm() ? 0 : focusedEntity.getYaw(), Config.isAntfarm() ? 0 : focusedEntity.getPitch());
this.setPos(Config.isAntfarm() ? focusedEntity.getX() + 3 : focusedEntity.getX(), focusedEntity.prevY + this.cameraY, focusedEntity.getZ());
}
if (thirdPerson) {
if (inverseView) {
Expand Down Expand Up @@ -97,6 +94,4 @@ public void getSubmersionType(CallbackInfoReturnable<CameraSubmersionType> cir){
}

}


}
26 changes: 26 additions & 0 deletions src/main/java/rubyboat/ghost/mixin/ClientPlayerEntityMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package rubyboat.ghost.mixin;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.input.Input;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.text.Text;
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.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import rubyboat.ghost.client.GhostClient;
import rubyboat.ghost.config.Config;

@Mixin(ClientPlayerEntity.class)
public class ClientPlayerEntityMixin {

@Inject(method = "tickMovement", at = @At("RETURN"))
public void returntick(CallbackInfo ci) {
if(Config.isAntfarm()) {
((ClientPlayerEntity)(Object)this).setPosition(Math.floor(((ClientPlayerEntity)(Object)this).getX()) + 0.5, ((ClientPlayerEntity)(Object)this).getY(), ((ClientPlayerEntity)(Object)this).getZ());
}
}
}
20 changes: 20 additions & 0 deletions src/main/java/rubyboat/ghost/mixin/ClientWorldMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.block.entity.BeaconBlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.world.ClientChunkManager;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
Expand Down Expand Up @@ -35,6 +36,8 @@ public abstract class ClientWorldMixin {

@Shadow public abstract void setTimeOfDay(long timeOfDay);

@Shadow public abstract ClientChunkManager getChunkManager();

@Inject(at = @At("HEAD"), method = "tick")
public void tick(CallbackInfo ci)
{
Expand All @@ -45,6 +48,23 @@ public void tick(CallbackInfo ci)
BlockPos suggestedBlockpos = this.client.player.getBlockPos().add(0,-1,0);
this.setBlockStateWithoutNeighborUpdates(suggestedBlockpos, Registry.BLOCK.get(new Identifier("minecraft", Config.getBlock())).getDefaultState());
}
}
if(Config.isAntfarm())
{
BlockPos pos = this.client.player.getBlockPos().add(10,0,0);
for(BlockPos blockpos : BlockPos.iterate(pos.add(-10,0,5), pos.add(0,0,-2)))
{
if(((ClientWorld)(Object)this).getBlockState(blockpos).getBlock() != Blocks.AIR)
{
for(BlockPos block : BlockPos.iterate(pos.add(-9,-10,-20), pos.add(10,10,20)))
{
setBlockStateWithoutNeighborUpdates(block, Blocks.AIR.getDefaultState());
}
break;
}
}


}
if(Config.time() != -1){
this.setTimeOfDay(Config.time());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rubyboat/ghost/mixin/DebugHudMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected void getLayer(CallbackInfoReturnable<List<String>> cir) {
LongSet longSet = world instanceof ServerWorld ? ((ServerWorld)world).getForcedChunks() : LongSets.EMPTY_SET;
var10000 = new String[7];
var10003 = SharedConstants.getGameVersion().getName();
var10000[0] = Config.getTitle() + var10003 + " (" + this.client.getGameVersion() + "/" + ClientBrandRetriever.getClientModName() + ("release".equalsIgnoreCase(this.client.getVersionType()) ? "" : "/" + this.client.getVersionType()) + ")";
var10000[0] = Config.getTitle() + " " + var10003 + " (" + this.client.getGameVersion() + "/" + ClientBrandRetriever.getClientModName() + ("release".equalsIgnoreCase(this.client.getVersionType()) ? "" : "/" + this.client.getVersionType()) + ")";
var10000[1] = this.client.fpsDebugString;
var10000[2] = string;
var10000[3] = this.client.worldRenderer.getChunksDebugString();
Expand Down
11 changes: 7 additions & 4 deletions src/main/resources/ghost.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
"BlockMixin",
"CameraMixin",
"ClientWorldMixin",
"DebugHudMixin",
"EndPortalRendererMixin",
"gameRendererMixin",
"MinecraftClientMixin",
"PlayerRenderMixin",
"DebugHudMixin",
"gameRendererMixin"
"PlayerRenderMixin"
],
"injectors": {
"defaultRequire": 1
}
},
"mixins": [
"ClientPlayerEntityMixin"
]
}

0 comments on commit 98624c8

Please sign in to comment.