Skip to content

Commit 867d0af

Browse files
committed
Update 1.2.0
1 parent 6e97778 commit 867d0af

File tree

32 files changed

+840
-79
lines changed

32 files changed

+840
-79
lines changed

client/src/main/java/com/fox2code/foxloader/client/mixins/MixinEntity.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@
33
import com.fox2code.foxloader.registry.RegisteredEntity;
44
import com.fox2code.foxloader.registry.RegisteredWorld;
55
import net.minecraft.src.game.entity.Entity;
6+
import net.minecraft.src.game.entity.other.EntityItem;
67
import net.minecraft.src.game.level.World;
78
import org.spongepowered.asm.mixin.Mixin;
89
import org.spongepowered.asm.mixin.Shadow;
910

1011
@Mixin(Entity.class)
11-
public class MixinEntity implements RegisteredEntity {
12+
public abstract class MixinEntity implements RegisteredEntity {
1213
@Shadow public double posX;
1314
@Shadow public double posY;
1415
@Shadow public double posZ;
1516
@Shadow public World worldObj;
17+
@Shadow public Entity ridingEntity;
18+
@Shadow public Entity riddenByEntity;
19+
20+
@Shadow public abstract void setPosition(double var1, double var3, double var5);
21+
@Shadow protected abstract void kill();
1622

1723
@Override
1824
public RegisteredWorld getCurrentRegisteredWorld() {
@@ -33,4 +39,24 @@ public double getRegisteredY() {
3339
public double getRegisteredZ() {
3440
return this.posZ;
3541
}
42+
43+
@Override
44+
public void teleportRegistered(double x, double y, double z) {
45+
this.setPosition(x, y, z);
46+
}
47+
48+
@Override
49+
public void killRegistered() {
50+
this.kill();
51+
}
52+
53+
@Override
54+
public RegisteredEntity getRegisteredRidding() {
55+
return (RegisteredEntity) this.ridingEntity;
56+
}
57+
58+
@Override
59+
public RegisteredEntity getRegisteredRiddenBy() {
60+
return (RegisteredEntity) this.riddenByEntity;
61+
}
3662
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.fox2code.foxloader.client.mixins;
2+
3+
import com.fox2code.foxloader.loader.ClientMod;
4+
import com.fox2code.foxloader.registry.RegisteredEntityItem;
5+
import com.fox2code.foxloader.registry.RegisteredItemStack;
6+
import net.minecraft.src.game.entity.other.EntityItem;
7+
import net.minecraft.src.game.item.ItemStack;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.Shadow;
10+
11+
import java.util.Objects;
12+
13+
@Mixin(EntityItem.class)
14+
public class MixinEntityItem implements RegisteredEntityItem {
15+
@Shadow public ItemStack item;
16+
17+
@Override
18+
public RegisteredItemStack getRegisteredItemStack() {
19+
return ClientMod.toRegisteredItemStack(this.item);
20+
}
21+
22+
@Override
23+
public void setRegisteredItemStack(RegisteredItemStack registeredItemStack) {
24+
this.item = ClientMod.toItemStack(Objects.requireNonNull(registeredItemStack));
25+
}
26+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.fox2code.foxloader.client.mixins;
2+
3+
import com.fox2code.foxloader.registry.RegisteredEntity;
4+
import com.fox2code.foxloader.registry.RegisteredEntityLiving;
5+
import net.minecraft.src.game.effect.Effect;
6+
import net.minecraft.src.game.entity.Entity;
7+
import net.minecraft.src.game.entity.EntityLiving;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.Shadow;
10+
11+
@Mixin(EntityLiving.class)
12+
public abstract class MixinEntityLiving implements RegisteredEntityLiving {
13+
@Shadow
14+
private Entity currentTarget;
15+
@Shadow public int[] effecttimers;
16+
@Shadow public byte[] effectlevel;
17+
18+
@Shadow public abstract boolean hasEffect(Effect effect);
19+
20+
@Override
21+
public RegisteredEntity getRegisteredTarget() {
22+
return (RegisteredEntity) this.currentTarget;
23+
}
24+
25+
@Override
26+
public void setRegisteredTarget(RegisteredEntity registeredTarget) {
27+
this.currentTarget = (Entity) registeredTarget;
28+
}
29+
30+
@Override
31+
public boolean getRegisteredHasEffect(int effectId) {
32+
return this.hasEffect(Effect.effectlist[effectId]);
33+
}
34+
35+
@Override
36+
public int getRegisteredEffectTimer(int effectId) {
37+
return this.effecttimers[effectId];
38+
}
39+
40+
@Override
41+
public int getRegisteredEffectLevel(int effectId) {
42+
return this.effecttimers[effectId] <= 0 ? 0 : this.effectlevel[effectId];
43+
}
44+
45+
@Override
46+
public void giveEffectRegistered(int effectId, int effectLevel, int effectDuration) {
47+
Effect.applyEffect((EntityLiving) (Object) this, effectId, effectLevel, effectDuration);
48+
}
49+
}

client/src/main/java/com/fox2code/foxloader/client/mixins/MixinGameSettings.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,4 @@ public void onLoadOptionInit(GameSettings instance) {
2727
public void onOptionInit(CallbackInfo ci) {
2828
this.keyBindings = KeyBindingAPI.Internal.inject(this.keyBindings);
2929
}
30-
31-
// Temporary hotfix.
32-
@Shadow public int limitFramerate;
33-
34-
@Inject(method = "getKeyBinding", at = @At("HEAD"))
35-
public void hotfix_onGetKeyBinding(EnumOptions option, CallbackInfoReturnable<String> cir) {
36-
if (option == EnumOptions.FRAMERATE_LIMIT && this.limitFramerate > 2 &&
37-
!EnumOptions.FRAMERATE_LIMIT.getEnumFloat()) {
38-
this.limitFramerate = 0;
39-
}
40-
}
4130
}

client/src/main/java/com/fox2code/foxloader/client/mixins/MixinWorld.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.fox2code.foxloader.client.mixins;
22

3+
import com.fox2code.foxloader.loader.ClientMod;
34
import com.fox2code.foxloader.network.NetworkPlayer;
4-
import com.fox2code.foxloader.registry.RegisteredEntity;
5-
import com.fox2code.foxloader.registry.RegisteredTileEntity;
6-
import com.fox2code.foxloader.registry.RegisteredWorld;
5+
import com.fox2code.foxloader.registry.*;
76
import net.minecraft.src.game.block.tileentity.TileEntity;
87
import net.minecraft.src.game.entity.Entity;
8+
import net.minecraft.src.game.entity.other.EntityItem;
99
import net.minecraft.src.game.entity.player.EntityPlayer;
1010
import net.minecraft.src.game.level.World;
1111
import org.spongepowered.asm.mixin.Mixin;
@@ -15,18 +15,16 @@
1515

1616
@Mixin(World.class)
1717
public abstract class MixinWorld implements RegisteredWorld {
18-
@Shadow public abstract int getBlockId(int x, int y, int z);
19-
@Shadow public abstract int getBlockMetadata(int xCoord, int yCoord, int zCoord);
20-
@Shadow public abstract boolean setBlockAndMetadataWithNotify(int xCoord, int yCoord, int zCoord, int block, int metadata);
21-
2218
@Shadow public List<EntityPlayer> playerEntities;
23-
2419
@Shadow public List<TileEntity> loadedTileEntityList;
25-
2620
@Shadow public List<Entity> loadedEntityList;
27-
2821
@Shadow public boolean multiplayerWorld;
2922

23+
@Shadow public abstract int getBlockId(int x, int y, int z);
24+
@Shadow public abstract int getBlockMetadata(int xCoord, int yCoord, int zCoord);
25+
@Shadow public abstract boolean setBlockAndMetadataWithNotify(int xCoord, int yCoord, int zCoord, int block, int metadata);
26+
@Shadow public abstract boolean entityJoinedWorld(Entity entity);
27+
3028
@Override
3129
public boolean hasRegisteredControl() {
3230
return !this.multiplayerWorld;
@@ -55,6 +53,16 @@ public void forceSetRegisteredBlockAndMetadataWithNotify(int xCoord, int yCoord,
5553
this.setBlockAndMetadataWithNotify(xCoord, yCoord, zCoord, block, metadata);
5654
}
5755

56+
@Override
57+
public RegisteredEntityItem spawnRegisteredEntityItem(double x, double y, double z, RegisteredItemStack registeredItemStack) {
58+
EntityItem entityItem = new EntityItem((World) (Object) this,
59+
x, y, z, ClientMod.toItemStack(registeredItemStack));
60+
if (!this.entityJoinedWorld(entityItem)) {
61+
return null;
62+
}
63+
return (RegisteredEntityItem) entityItem;
64+
}
65+
5866
@Override
5967
@SuppressWarnings("unchecked")
6068
public List<? extends RegisteredEntity> getRegisteredEntities() {

client/src/main/java/com/fox2code/foxloader/registry/GameRegistryClient.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
import com.fox2code.foxloader.loader.packet.ServerHello;
99
import net.minecraft.src.client.gui.StringTranslate;
1010
import net.minecraft.src.game.block.*;
11-
import net.minecraft.src.game.item.Item;
12-
import net.minecraft.src.game.item.ItemBlock;
13-
import net.minecraft.src.game.item.ItemBlockSlab;
14-
import net.minecraft.src.game.item.ItemStack;
11+
import net.minecraft.src.game.item.*;
1512
import net.minecraft.src.game.recipe.*;
1613

1714
import java.lang.reflect.Constructor;
@@ -232,6 +229,12 @@ public Block registerNewBlock0(String name, BlockBuilder blockBuilder, int fallb
232229
if (blockBuilder.abilityToCatchFire != 0) {
233230
abilityToCatchFire[blockId] = blockBuilder.abilityToCatchFire;
234231
}
232+
byte effectiveToolBit = blockBuilder.effectiveToolBit;
233+
for (EnumTools enumTool : EnumTools.values()) {
234+
if ((effectiveToolBit & (1 << enumTool.ordinal())) != 0) {
235+
block.setEffectiveTool(enumTool);
236+
}
237+
}
235238
if (blockBuilder.tooltipColor != 0) {
236239
block.setTooltipColor(blockBuilder.tooltipColor);
237240
}

client/src/main/resources/foxloader.client.mixins.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"MixinContainerCreative",
1212
"MixinEntity",
1313
"MixinEntityClientPlayerMP",
14+
"MixinEntityItem",
15+
"MixinEntityLiving",
1416
"MixinEntityPlayerSP",
1517
"MixinEntityRenderer",
1618
"MixinGameSettings",

common/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies {
88
api 'org.ow2.asm:asm-commons:9.5'
99
api 'org.semver4j:semver4j:4.3.0'
1010
api 'org.spongepowered:mixin:0.8.5'
11-
api 'com.github.LlamaLad7.MixinExtras:mixinextras-common:0.2.0-beta.6'
11+
api 'com.github.LlamaLad7.MixinExtras:mixinextras-common:0.2.0-beta.7'
1212

1313
// Mixin dependencies
1414
api 'com.google.code.gson:gson:2.2.4'

common/src/main/java/com/fox2code/foxloader/launcher/DependencyHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ GSON_DEPENDENCY, new Dependency("com.google.guava:guava:21.0", MAVEN_CENTRAL, "c
3030
new Dependency("org.semver4j:semver4j:4.3.0", MAVEN_CENTRAL, "org.semver4j.Semver"),
3131
new Dependency("org.apache.commons:commons-lang3:3.3.2", MAVEN_CENTRAL, "org.apache.commons.lang3.tuple.Pair"),
3232
new Dependency("org.spongepowered:mixin:0.8.5", SPONGE_POWERED, "org.spongepowered.asm.mixin.Mixins"),
33-
new Dependency("com.github.LlamaLad7.MixinExtras:mixinextras-common:0.2.0-beta.6",
33+
new Dependency("com.github.LlamaLad7.MixinExtras:mixinextras-common:0.2.0-beta.7",
3434
JITPACK, "com.llamalad7.mixinextras.MixinExtrasBootstrap"),
3535
};
3636

common/src/main/java/com/fox2code/foxloader/launcher/FoxClassLoader.java

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.*;
1212

1313
public final class FoxClassLoader extends URLClassLoader {
14+
private static final String CLASS_TO_DUMP = System.getProperty("foxloader.dump-class");
1415
private static final String MIXIN_CONFIG = "org.spongepowered.asm.mixin.transformer.MixinConfig";
1516
private static final String MIXIN_PRE_PROCESSOR = "org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard";
1617
private static final URL[] NO_URLs = new URL[0];
@@ -165,6 +166,9 @@ private Class<?> findClass(String name, URL resource) throws ClassNotFoundExcept
165166
if (urlConnection instanceof JarURLConnection) {
166167
url = ((JarURLConnection) urlConnection).getJarFileURL();
167168
}
169+
if (name.equals(CLASS_TO_DUMP)) {
170+
Files.write(new File(FoxLauncher.gameDir, "class_dump.class").toPath(), bytes);
171+
}
168172
clas = defineClass(name,bytes,0,bytes.length, url == null ?
169173
null : new CodeSource(url, new CodeSigner[]{}));
170174
return clas;
@@ -246,32 +250,47 @@ public void addCoreModURL(URL url) {
246250
public void setMinecraftURL(URL url) {
247251
if (allowLoadingGame)
248252
throw new IllegalStateException("Minecraft jar already loaded!");
249-
super.addURL(url);
253+
minecraftExclusiveSource = new URLClassLoader(makeURLClassPathForSource(url), null);
254+
}
255+
256+
public void setPatchedMinecraftURL(URL url) {
257+
if (allowLoadingGame)
258+
throw new IllegalStateException("Minecraft jar already loaded!");
259+
minecraftExclusiveSource = new URLClassLoader(new URL[]{url}, null);
260+
}
261+
262+
public URL[] makeURLClassPathForSource(URL source) {
250263
if (coreMods != null) {
251-
ArrayList<URL> urls = new ArrayList<>(coreMods); urls.add(url);
252-
minecraftExclusiveSource = new URLClassLoader(urls.toArray(NO_URLs), null);
264+
ArrayList<URL> urls = new ArrayList<>(coreMods); urls.add(source);
265+
return urls.toArray(NO_URLs);
253266
} else {
254-
minecraftExclusiveSource = new URLClassLoader(new URL[]{url}, null);
267+
return new URL[]{source};
255268
}
256269
}
257270

258271
public void allowLoadingGame() {
259272
if (allowLoadingGame) return;
260273
if (coreMods != null) {
261274
try {
262-
URLConnection urlConnection = Objects.requireNonNull(
263-
this.getResource("font.txt")).openConnection();
264-
if (urlConnection instanceof JarURLConnection) {
265-
setMinecraftURL(((JarURLConnection) urlConnection).getJarFileURL());
266-
coreMods = null;
267-
allowLoadingGame = true;
268-
} else throw new RuntimeException("Invalid reindev.jar source...");
275+
setMinecraftURL(getMinecraftSource());
276+
coreMods = null;
277+
allowLoadingGame = true;
269278
} catch (IOException e) {
270279
throw new RuntimeException(e);
271280
}
272281
} else allowLoadingGame = true;
273282
}
274283

284+
public URL getMinecraftSource() throws IOException {
285+
URLConnection urlConnection = Objects.requireNonNull(
286+
this.getResource("font.txt")).openConnection();
287+
if (urlConnection instanceof JarURLConnection) {
288+
return ((JarURLConnection) urlConnection).getJarFileURL();
289+
} else if (earlyMinecraftURL != null) {
290+
return earlyMinecraftURL;
291+
} else throw new IOException("Invalid reindev.jar source...");
292+
}
293+
275294
public boolean isAllowLoadingGame() {
276295
return allowLoadingGame;
277296
}

0 commit comments

Comments
 (0)