Skip to content

Commit

Permalink
Cleanup (#56)
Browse files Browse the repository at this point in the history
* update deps & enable modern+generic

* wtf is going on here

* minor cleanup - remove some nasty casts, rawtypes -> type,  remove commented code, make some bits more readable.

* removed unused classes. not touched for nearly a decade

* remove unnecessary reflection

* cleanup blocks & tiles

* applyDecompilerCleanupToMain

* spotless

* fix

* fix merge conflic

* address review

* delete 2 more unused classes

---------

Co-authored-by: Martin Robertz <[email protected]>
  • Loading branch information
Lyfts and Dream-Master authored Jul 20, 2024
1 parent 698fcdc commit 351df36
Show file tree
Hide file tree
Showing 102 changed files with 664 additions and 2,910 deletions.
5 changes: 3 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ dependencies {
implementation('com.github.GTNewHorizons:GT5-Unofficial:5.09.48.62:dev')
implementation('com.github.GTNewHorizons:ForbiddenMagic:0.7.0-GTNH:dev')
implementation('com.github.GTNewHorizons:twilightforest:2.6.27:dev')

implementation('curse.maven:travellers-gear-224440:2262113')
implementation('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')

implementation('com.github.GTNewHorizons:CodeChickenLib:1.3.0:dev')
implementation('com.github.GTNewHorizons:NotEnoughItems:2.6.11-GTNH:dev')

compileOnly('com.github.GTNewHorizons:ForgeMultipart:1.5.0:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:Botania:1.11.3-GTNH:api') {transitive=false}
compileOnly('com.github.GTNewHorizons:CraftTweaker:3.3.1:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:ZenScript:1.0.0-GTNH') {transitive=false}
compileOnly('com.github.GTNewHorizons:MagicBees:2.8.1-GTNH:api') {transitive=false}
compileOnly('com.github.GTNewHorizons:TinkersConstruct:1.12.2-GTNH:dev') {transitive=false}
compileOnly(deobfCurse('enviromine-230236:2269710'))

runtimeOnly('com.github.GTNewHorizons:Baubles:1.0.4:dev')
}
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ developmentEnvironmentUserName = Developer

# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = false
enableModernJavaSyntax = true

# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = false
enableGenericInjection = true

# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
generateGradleTokenClass =
generateGradleTokenClass = witchinggadgets.Tags

# Name of the token containing the project's current version to generate/replace.
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenVersion = VERSION

# [DEPRECATED] Mod ID replacement token.
gradleTokenModId =
Expand All @@ -70,7 +70,7 @@ gradleTokenGroupName =
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...]).
# Leave these properties empty to skip individual token replacements.
replaceGradleTokenInFile = WitchingGadgets.java
replaceGradleTokenInFile =

# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/witchinggadgets/WitchingGadgets.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class WitchingGadgets {

public static final String MODID = "WitchingGadgets";
public static final String MODNAME = "Witching Gadgets";
public static final String VERSION = "GRADLETOKEN_VERSION";
public static final String VERSION = Tags.VERSION;

public PlayerTickHandler playerTickHandler;

Expand Down
38 changes: 14 additions & 24 deletions src/main/java/witchinggadgets/client/ClientEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,12 @@ public void handleMouse(MouseEvent event) {
int my = event.y - mc.displayHeight / 2;
double radius = Math.sqrt(mx * mx + my * my);

double cx = mx / radius; // Math.cos(Math.toRadians(angle));
double cx = mx / radius;
double angle = (mx < 0 ? 180 : 0) + Math.abs(
(mx < 0 ? -180 : 0) + (my < 0 ? 90 : 0)
+ Math.abs((my < 0 ? -90 : 0) + Math.abs(Math.toDegrees(Math.acos(cx)) - 90)));
int sel = angle > 288 ? 0 : angle < 72 ? 1 : 2 + (int) ((288 - angle) / 72);
WitchingGadgets.packetHandler.sendToServer(new MessagePrimordialGlove(player, (byte) 0, sel));
// WGPacketPipeline.INSTANCE.sendToServer(new PacketPrimordialGlove(player, (byte)0, sel));
}
}

Expand All @@ -152,14 +151,14 @@ public void renderGameOverlay(RenderGameOverlayEvent.Pre event) {
ClientUtilities.bindTexture("witchinggadgets:textures/gui/steam_overlay.png");
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(0.0D, (double) event.resolution.getScaledHeight(), -90.0D, 0.0D, 1.0D);
tessellator.addVertexWithUV(0.0D, event.resolution.getScaledHeight(), -90.0D, 0.0D, 1.0D);
tessellator.addVertexWithUV(
(double) event.resolution.getScaledWidth(),
(double) event.resolution.getScaledHeight(),
event.resolution.getScaledWidth(),
event.resolution.getScaledHeight(),
-90.0D,
1.0D,
1.0D);
tessellator.addVertexWithUV((double) event.resolution.getScaledWidth(), 0.0D, -90.0D, 1.0D, 0.0D);
tessellator.addVertexWithUV(event.resolution.getScaledWidth(), 0.0D, -90.0D, 1.0D, 0.0D);
tessellator.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);
tessellator.draw();
GL11.glDepthMask(true);
Expand All @@ -175,7 +174,7 @@ public void renderGameOverlay(RenderGameOverlayEvent.Pre event) {
|| !(mc.thePlayer.getCurrentEquippedItem().getItem() instanceof ItemPrimordialGlove)))
WGKeyHandler.gemLock = false;

GL11.glEnable(3042);
GL11.glEnable(GL11.GL_BLEND);
double rad = 50 * WGKeyHandler.gemRadial;
int x = event.resolution.getScaledWidth() / 2;
int y = event.resolution.getScaledHeight() / 2;
Expand Down Expand Up @@ -217,8 +216,7 @@ public void renderGameOverlay(RenderGameOverlayEvent.Pre event) {
(my < 0 ? -90 : 0)
+ Math.abs(Math.toDegrees(Math.acos(mx / reverseRadius)) - 90)));
int sel = reverseAngle > 288 ? 0 : reverseAngle < 72 ? 1 : 2 + (int) ((288 - reverseAngle) / 72);
//
// mc.fontRenderer.drawString("mPos: "+mx+", "+my+", sel: "+sel, x, y, 0xffffff);

GL11.glPushMatrix();
for (int g = 0; g < gems.length; g++) if (gems[g] != null) {
int ix = (int) (((g == 0 ? -54 : g == 1 ? 13 : g == 3 ? -22 : g == 2 ? -76 : 35) / 256f) * rad * 2);
Expand All @@ -229,24 +227,16 @@ public void renderGameOverlay(RenderGameOverlayEvent.Pre event) {
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDepthMask(false);
ClientUtilities.bindTexture("witchinggadgets:textures/models/white.png");
GL11.glEnable(3042);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(770, 771);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

for (int j1 = 0; j1 < 2; ++j1) {
tessellator.startDrawingQuads();
tessellator.setColorRGBA_I(0, 64);
tessellator.addVertexWithUV(ix - 2 + 00, iy - 2 + 20, 50, 0, 1); // ((f2 + (float)p5 * f4) *
// f), )((f3 + (float)p5) *
// f1));
tessellator.addVertexWithUV(ix - 2 + 20, iy - 2 + 20, 50, 1, 1); // ((f2 + (float)p4 +
// (float)p5 * f4) * f),
// ((f3 + (float)p5) *
// f1));
tessellator.addVertexWithUV(ix - 2 + 20, iy - 2 + 00, 50, 1, 0); // ((f2 + (float)p4) * f),
// ((f3 + 0.0F) * f1));
tessellator.addVertexWithUV(ix - 2 + 00, iy - 2 + 00, 50, 0, 0); // ((f2 + 0.0F) * f), ((f3
// + 0.0F) * f1));
tessellator.addVertexWithUV(ix - 2, iy - 2 + 20, 50, 0, 1);
tessellator.addVertexWithUV(ix - 2 + 20, iy - 2 + 20, 50, 1, 1);
tessellator.addVertexWithUV(ix - 2 + 20, iy - 2, 50, 1, 0);
tessellator.addVertexWithUV(ix - 2, iy - 2, 50, 0, 0);
tessellator.draw();
}

Expand Down Expand Up @@ -329,7 +319,7 @@ public void setSpecialRendersLiving(RenderLivingEvent.Pre event) {
.getPlayerEntityByName(event.entity.getCommandSenderName());
if (pl != null) for (ItemStack cloak : Utilities.getActiveMagicalCloak(pl))
if (cloak != null && cloak.hasTagCompound() && cloak.getTagCompound().getBoolean("isSpectral")) {
GL11.glEnable(3042);
GL11.glEnable(GL11.GL_BLEND);
boolean goggles = Minecraft.getMinecraft().thePlayer.getEquipmentInSlot(4) != null
&& (Minecraft.getMinecraft().thePlayer.getEquipmentInSlot(4).getItem() instanceof IRevealer
|| Minecraft.getMinecraft().thePlayer.getEquipmentInSlot(4)
Expand All @@ -355,7 +345,7 @@ public void resetResetSpecialLiving(RenderLivingEvent.Post event) {
.getPlayerEntityByName(event.entity.getCommandSenderName());
if (pl != null) for (ItemStack cloak : Utilities.getActiveMagicalCloak(pl))
if (cloak != null && cloak.hasTagCompound() && cloak.getTagCompound().getBoolean("isSpectral")) {
GL11.glDisable(3042);
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor4f(1, 1, 1, 1);
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/witchinggadgets/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ public void registerRenders() {
MinecraftForgeClient.registerItemRenderer(WGContent.ItemCapsule, new ItemRenderCapsule());

RenderingRegistry.registerEntityRenderingHandler(EntityItemReforming.class, new EntityRenderReforming());
// MinecraftForgeClient.registerItemRenderer(WGContent.BlockWoodenDevice.blockID, new
// ItemRenderSpinningWheel());
}

public void registerHandlers() {
Expand Down
17 changes: 4 additions & 13 deletions src/main/java/witchinggadgets/client/ClientTickHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@

public class ClientTickHandler {

public static HashMap<ChunkCoordinates, Integer> oreHighlightMap = new HashMap();
public static HashMap<ChunkCoordinates, Object> oreHighlightBeamMap = new HashMap();
public static HashMap<ChunkCoordinates, Integer> oreHighlightMap = new HashMap<>();
public static HashMap<ChunkCoordinates, Object> oreHighlightBeamMap = new HashMap<>();
static int highlight;

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void renderTick(TickEvent.RenderTickEvent event) {
if (!(Minecraft.getMinecraft().renderViewEntity instanceof EntityPlayer)) return;
EntityPlayer player = (EntityPlayer) Minecraft.getMinecraft().renderViewEntity;
if (player == null || oreHighlightMap.isEmpty()) {
oreHighlightMap.clear();
if (!(Minecraft.getMinecraft().renderViewEntity instanceof EntityPlayer player)) return;
if (oreHighlightMap.isEmpty()) {
oreHighlightBeamMap.clear();
highlight = 0;
return;
Expand All @@ -43,18 +41,11 @@ public void renderTick(TickEvent.RenderTickEvent event) {

double[] hand = ClientUtilities.getPlayerHandPos(player, true);

// Thaumcraft.proxy.wispFX3(player.worldObj, hand[0],hand[1],hand[2], x,y,z, .15f,3,false,0);
FXWisp ef = new FXWisp(player.worldObj, hand[0], hand[1], hand[2], x, y, z, .05f, 3);
ef.noClip = true;
ef.setGravity(0);
ef.shrink = true;

ParticleEngine.instance.addEffect(player.worldObj, ef);

// oreHighlightBeamMap.put(e.getKey(), Thaumcraft.proxy.beamPower(player.worldObj, hand[0],hand[1],hand[2],
// x,y,z, 0, 1, 0, true, oreHighlightBeamMap.get(e.getKey())));//beamBore(Minecraft.getMinecraft().theWorld,
// x,y,z, hand[0],hand[1],hand[2], 1,Aspect.EARTH.getColor(), true, .2f,
// oreHighlightBeamMap.get(e.getKey()), 0));
highlight++;
if (highlight >= oreHighlightMap.size()) highlight = 0;
}
Expand Down
Loading

0 comments on commit 351df36

Please sign in to comment.