-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from telvarost/1-port-mod-from-cursed-legacy-fa…
…bric 1 port mod from cursed legacy fabric
- Loading branch information
Showing
29 changed files
with
1,617 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
src/main/java/com/github/telvarost/finalbeta/ModHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.github.telvarost.finalbeta; | ||
|
||
import net.glasslauncher.mods.api.gcapi.api.ConfigName; | ||
import net.minecraft.block.BlockBase; | ||
import net.minecraft.entity.player.PlayerBase; | ||
import net.minecraft.item.ItemBase; | ||
import net.minecraft.item.ItemInstance; | ||
import net.minecraft.stat.Stats; | ||
import net.minecraft.client.Minecraft; | ||
|
||
import java.lang.reflect.Field; | ||
import java.time.Duration; | ||
import java.util.Random; | ||
|
||
public class ModHelper { | ||
|
||
public static Minecraft getInstance() { | ||
try { | ||
Field f = Minecraft.class.getDeclaredField("instance"); | ||
f.setAccessible(true); | ||
return (Minecraft) f.get(null); | ||
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { | ||
e.printStackTrace(); | ||
} | ||
return null; | ||
} | ||
|
||
public static long getRealDaysPlayed() { | ||
int seconds = ModHelper.getInstance().statFileWriter.write(Stats.playOneMinute) / 20; | ||
return Duration.ofSeconds(seconds).toDays(); | ||
} | ||
|
||
public static long getGameDaysPlayed() { | ||
int seconds = ModHelper.getInstance().statFileWriter.write(Stats.playOneMinute) / 20; | ||
return Duration.ofSeconds(seconds).toMinutes() / 20; | ||
} | ||
|
||
public static float lerp(float delta, float start, float end) { | ||
return start + delta * (end - start); | ||
} | ||
|
||
public static float clamp(float val, float min, float max) { | ||
return val < min ? min : Math.min(val, max); | ||
} | ||
|
||
public static class ModHelperFields { | ||
|
||
public static Boolean ENABLE_CLOUDS = true; | ||
|
||
public static Boolean IS_LAVA_BUCKET_CONSUMED = false; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/github/telvarost/finalbeta/mixin/BipedRendererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.github.telvarost.finalbeta.mixin; | ||
|
||
import com.github.telvarost.finalbeta.Config; | ||
import org.lwjgl.opengl.GL11; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.At.Shift; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import net.minecraft.client.render.entity.BipedEntityRenderer; | ||
import net.minecraft.entity.Living; | ||
import net.minecraft.item.ItemInstance; | ||
import net.minecraft.item.ItemBase; | ||
|
||
@Mixin(BipedEntityRenderer.class) | ||
public class BipedRendererMixin { | ||
|
||
@Inject( | ||
method = "method_827", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/class_556;method_1862(Lnet/minecraft/entity/Living;Lnet/minecraft/item/ItemInstance;)V", | ||
shift = Shift.BEFORE | ||
) | ||
) | ||
public void finalBeta_playerRendering(Living entity, float f, CallbackInfo ci) { | ||
if(Config.ConfigFields.FIX_BOW_MODEL) { | ||
ItemInstance item = entity.getMonsterHeldItem(); // this may be wrong .getMonsterHeldItem() | ||
if (item != null && item.itemId == ItemBase.bow.id) { | ||
GL11.glRotatef(-5, 1, 0, 0); | ||
GL11.glTranslatef(0.2F, -0.5F, 0.2F); | ||
} | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/github/telvarost/finalbeta/mixin/BowItemMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.github.telvarost.finalbeta.mixin; | ||
|
||
import com.github.telvarost.finalbeta.Config; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import net.minecraft.item.ItemBase; | ||
import net.minecraft.item.tool.Bow; | ||
|
||
@Mixin(Bow.class) | ||
public class BowItemMixin { | ||
@Inject(method = "<init>(I)V", at = @At("TAIL")) | ||
public void finalBeta_initBow(int i, CallbackInfo ci) { | ||
if(Config.ConfigFields.FIX_BOW_MODEL) { | ||
ItemBase item = ((ItemBase) (Object) this); | ||
item.setRendered3d(); | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/main/java/com/github/telvarost/finalbeta/mixin/ClientPlayerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//package com.github.telvarost.finalbeta.mixin; | ||
// | ||
//import com.github.telvarost.finalbeta.Config; | ||
//import com.github.telvarost.finalbeta.ModHelper; | ||
//import java.util.Random; | ||
// | ||
//import net.minecraft.client.Minecraft; | ||
//import net.minecraft.client.gui.screen.container.DoubleChest; | ||
//import net.minecraft.client.util.Session; | ||
//import net.minecraft.entity.player.AbstractClientPlayer; | ||
//import net.minecraft.level.Level; | ||
//import net.minecraft.network.ClientPlayNetworkHandler; | ||
//import org.lwjgl.input.Keyboard; | ||
//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 net.minecraft.container.Chest; | ||
//import net.minecraft.entity.player.ClientPlayer; | ||
//import net.minecraft.entity.player.PlayerBase; | ||
//import net.minecraft.inventory.InventoryBase; | ||
// | ||
//@Mixin(ClientPlayer.class) | ||
//public class ClientPlayerMixin extends AbstractClientPlayer { | ||
// | ||
// private Random rand = new Random(); | ||
// | ||
// @Shadow | ||
// public ClientPlayNetworkHandler networkHandler; | ||
// | ||
// public ClientPlayerMixin(Minecraft minecraft, Level arg, Session arg2, ClientPlayNetworkHandler arg3) { | ||
// super(minecraft, arg, arg2, 0); | ||
// this.networkHandler = arg3; | ||
// } | ||
// | ||
// @Override | ||
// public void finalBeta_openChestScreen(InventoryBase arg) { | ||
// this.minecraft.openScreen(new DoubleChest(this.inventory, arg)); | ||
// | ||
// if(Config.ConfigFields.ADD_MORE_SOUNDS) { | ||
// PlayerBase player = (PlayerBase) (Object) this; | ||
// player.level.playSound(player, "random.chestopen", 0.3f, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); | ||
// } | ||
// } | ||
// | ||
// @Inject(method = "closeContainer", at = @At("HEAD")) | ||
// public void finalBeta_closeContainer(CallbackInfo ci) { | ||
// if(Config.ConfigFields.ADD_MORE_SOUNDS) { | ||
// PlayerBase player = (PlayerBase) (Object) this; | ||
// if(player.container instanceof Chest) { | ||
// player.level.playSound(player, "random.chestclosed", 0.3f, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); | ||
// } | ||
// } | ||
// } | ||
//} |
Oops, something went wrong.