Skip to content

Commit

Permalink
1.19.4 port progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Lothrazar committed Jun 11, 2023
1 parent 5408ad5 commit 0e38d1d
Show file tree
Hide file tree
Showing 24 changed files with 90 additions and 107 deletions.
21 changes: 7 additions & 14 deletions src/main/java/com/lothrazar/cyclic/event/ItemEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,33 +237,26 @@ public void onEntityDamage(LivingDamageEvent event) {
DamageSource src = event.getSource();
if (event.getEntity() instanceof Player player) {
DamageType type = src.type();
//lol waht
// DamageTypes.EXPLOSION.cast(null)
if (src.isExplosion()) {
if (src.is(DamageTypes.EXPLOSION)) {
//explosion thingy
this.damageFinder(event, player, ItemRegistry.CHARM_CREEPER.get(), 0);
}
//check all cases
//SB switch
if (src.is(DamageTypes.FALL)) {
//oh shit its this easy lol
}
if (src == DamageSource.FALL || src == DamageSource.CACTUS || src == DamageSource.SWEET_BERRY_BUSH) {
if (src.is(DamageTypes.FALL) || src.is(DamageTypes.CACTUS) || src.is(DamageTypes.SWEET_BERRY_BUSH)) {
this.damageFinder(event, player, ItemRegistry.CHARM_LONGFALL.get(), 0);
}
else if (src == DamageSource.FLY_INTO_WALL || src == DamageSource.IN_WALL) {
else if (src.is(DamageTypes.FLY_INTO_WALL) || src.is(DamageTypes.IN_WALL)) {
//stone lung
this.damageFinder(event, player, ItemRegistry.CHARM_STONE.get(), 0);
}
else if (src == DamageSource.MAGIC || src == DamageSource.DRAGON_BREATH) {
else if (src.is(DamageTypes.MAGIC) || src.is(DamageTypes.DRAGON_BREATH)) {
this.damageFinder(event, player, ItemRegistry.CHARM_MAGICDEF.get(), 0.5F);
}
else if (src == DamageSource.STARVE) {
else if (src.is(DamageTypes.STARVE)) {
if (this.damageFinder(event, player, ItemRegistry.CHARM_STARVATION.get(), 0)) {
player.getFoodData().eat(0, 0.2F);
}
}
else if (src == DamageSource.DROWN) {
else if (src.is(DamageTypes.DROWN)) {
if (this.damageFinder(event, player, ItemRegistry.CHARM_WATER.get(), 0)) {
//and a holdover bonus
MobEffectInstance eff = new MobEffectInstance(MobEffects.WATER_BREATHING, 20 * 10, 1);
Expand All @@ -272,7 +265,7 @@ else if (src == DamageSource.DROWN) {
player.addEffect(eff);
}
}
else if (src == DamageSource.LAVA || src == DamageSource.IN_FIRE || src == DamageSource.ON_FIRE) {
else if (src.is(DamageTypes.LAVA) || src.is(DamageTypes.IN_FIRE) || src.is(DamageTypes.ON_FIRE)) {
this.damageFinder(event, player, ItemRegistry.CHARM_FIRE.get(), 0);
this.damageFinder(event, player, ItemRegistry.CHARM_ULTIMATE.get(), 0);
}
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/com/lothrazar/cyclic/gui/ButtonTextured.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.lothrazar.cyclic.registry.TextureRegistry;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -38,9 +37,9 @@ public void setTextureId(TextureEnum id) {
}

@Override
public void renderButton(PoseStack ms, int mouseX, int mouseY, float partial) {
super.renderButton(ms, mouseX, mouseY, partial);
Minecraft minecraft = Minecraft.getInstance();
public void renderWidget(PoseStack ms, int mouseX, int mouseY, float partial) {
super.renderWidget(ms, mouseX, mouseY, partial);
// Minecraft minecraft = Minecraft.getInstance();
// minecraft.getTextureManager().bind(TextureRegistry.WIDGETS);
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, TextureRegistry.WIDGETS);
Expand All @@ -53,7 +52,7 @@ public void renderButton(PoseStack ms, int mouseX, int mouseY, float partial) {
textureId.getX() + xOffset, textureId.getY() + yOffset,
textureId.getWidth() - yOffset, textureId.getHeight() - yOffset);
}
this.renderBg(ms, minecraft, mouseX, mouseY);
// this.renderBg(ms, minecraft, mouseX, mouseY);
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/lothrazar/cyclic/gui/FluidBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public void draw(PoseStack ms, FluidStack fluid) {
}

protected void drawTiledSprite(PoseStack stack, int xPosition, int yPosition, int yOffset, int desiredWidth, int desiredHeight, TextureAtlasSprite sprite) {
RenderUtils.drawTiledSprite(stack.last().pose(), xPosition, yPosition, yOffset, desiredWidth, desiredHeight, sprite, width - 2, width - 2, parent.getBlitOffset());
//32 stack.getBlitOffset() ?
RenderUtils.drawTiledSprite(stack.last().pose(), xPosition, yPosition, yOffset, desiredWidth, desiredHeight, sprite, width - 2, width - 2, 32);
}

public boolean isMouseover(int mouseX, int mouseY) {
Expand Down
42 changes: 19 additions & 23 deletions src/main/java/com/lothrazar/cyclic/gui/GuiSliderInteger.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
import com.lothrazar.cyclic.api.IHasTooltip;
import com.lothrazar.cyclic.net.PacketTileData;
import com.lothrazar.cyclic.registry.PacketRegistry;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.AbstractSliderButton;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
Expand All @@ -38,29 +35,28 @@ public GuiSliderInteger(int x, int y, int width, int height, int field,
this.max = max;
setSliderValueActual((int) initialVal);
}

/**
* exact copy of super() but replaced hardcoded 20 with this.height
*/
@Override
protected void renderBg(PoseStack matrixStack, Minecraft minecraft, int mouseX, int mouseY) {
// minecraft.getTextureManager().bind(WIDGETS_LOCATION);
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, WIDGETS_LOCATION);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
int i = (this.isHovered ? 2 : 1) * 20;
if (this.height != 20) {
this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)), this.getY(), 0, 46 + i + 20 - this.height, 4, this.height);
this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)) + 4, this.getY(), 196, 46 + i + 20 - this.height, 4, this.height);
int height = this.height - 2;
this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)), this.getY(), 0, 46 + i, 4, height);
this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)) + 4, this.getY(), 196, 46 + i, 4, height);
}
else {
this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)), this.getY(), 0, 46 + i, 4, this.height);
this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)) + 4, this.getY(), 196, 46 + i, 4, this.height);
}
}
// @Override
// protected void renderWidget(PoseStack matrixStack, Minecraft minecraft, int mouseX, int mouseY) {
// // minecraft.getTextureManager().bind(WIDGETS_LOCATION);
// RenderSystem.setShader(GameRenderer::getPositionTexShader);
// RenderSystem.setShaderTexture(0, WIDGETS_LOCATION);
// RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
// int i = (this.isHovered ? 2 : 1) * 20;
// if (this.height != 20) {
// this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)), this.getY(), 0, 46 + i + 20 - this.height, 4, this.height);
// this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)) + 4, this.getY(), 196, 46 + i + 20 - this.height, 4, this.height);
// int height = this.height - 2;
// this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)), this.getY(), 0, 46 + i, 4, height);
// this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)) + 4, this.getY(), 196, 46 + i, 4, height);
// }
// else {
// this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)), this.getY(), 0, 46 + i, 4, this.height);
// this.blit(matrixStack, this.getX() + (int) (this.value * (this.width - 8)) + 4, this.getY(), 196, 46 + i, 4, this.height);
// }
// }

/**
* Call from Screen class to render tooltip during mouseover
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/lothrazar/cyclic/gui/TextBoxAutosave.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public TextBoxAutosave(Font fontIn, int xIn, int yIn, int widthIn, BlockPos pos,
}

@Override
protected void onFocusedChanged(boolean onFocusedChanged) {
super.onFocusedChanged(onFocusedChanged);
public void setFocused(boolean onFocusedChanged) {
super.setFocused(onFocusedChanged);
saveValue();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/lothrazar/cyclic/gui/TextboxInteger.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public TextboxInteger(Font fontIn, int xIn, int yIn, int widthIn,
}

@Override
protected void onFocusedChanged(boolean onFocusedChanged) {
super.onFocusedChanged(onFocusedChanged);
public void setFocused(boolean onFocusedChanged) {
super.setFocused(onFocusedChanged);
saveValue();
}

Expand Down
28 changes: 14 additions & 14 deletions src/main/java/com/lothrazar/cyclic/item/bauble/SoulstoneCharm.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ public static boolean checkTotemDeathProtection(DamageSource damageSourceIn, Pla
if (itemstack.getItem() != ItemRegistry.SOULSTONE.get()) {
return false;
}
if (damageSourceIn.isBypassInvul()) {
// /kill command and other OP sources can bypass
return false;
}
else {
player.setHealth(1.0F);
player.removeAllEffects();
player.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 900, 1));
player.addEffect(new MobEffectInstance(MobEffects.ABSORPTION, 100, 1));
player.addEffect(new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 800, 0));
player.level.broadcastEntityEvent(player, (byte) 35);
ItemStackUtil.damageItem(player, itemstack);
return true;
}
// if (damageSourceIn.isBypassInvul()) {
// /kill command and other OP sources can bypass
// return false;
// }
// else {
player.setHealth(1.0F);
player.removeAllEffects();
player.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 900, 1));
player.addEffect(new MobEffectInstance(MobEffects.ABSORPTION, 100, 1));
player.addEffect(new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 800, 0));
player.level.broadcastEntityEvent(player, (byte) 35);
ItemStackUtil.damageItem(player, itemstack);
return true;
// }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
Expand Down Expand Up @@ -276,7 +275,7 @@ private void onImpactEntity(EntityHitResult entityRayTrace) {
if (entityHit instanceof LivingEntity) {
LivingEntity live = (LivingEntity) entityHit;
float damage = Mth.nextFloat(level.random, DAMAGE_MIN, DAMAGE_MAX);
boolean attackSucc = live.hurt(DamageSource.thrown(this, owner), damage);
boolean attackSucc = live.hurt(level.damageSources().thrown(this, owner), damage);
if (attackSucc && live.isAlive() == false) {
// ("killed one");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void slotsChanged(Container inventory) {
if (optional.isPresent()) {
CraftingRecipe icraftingrecipe = optional.get();
if (craftResult.setRecipeUsed(world, player, icraftingrecipe)) {
itemstack = icraftingrecipe.assemble(craftMatrix);
itemstack = icraftingrecipe.assemble(craftMatrix, world.registryAccess());
}
}
craftResult.setItem(0, itemstack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void slotsChanged(Container inventory) {
if (optional.isPresent()) {
CraftingRecipe icraftingrecipe = optional.get();
if (craftResult.setRecipeUsed(world, player, icraftingrecipe)) {
itemstack = icraftingrecipe.assemble(craftMatrix);
itemstack = icraftingrecipe.assemble(craftMatrix, world.registryAccess());
}
}
craftResult.setItem(0, itemstack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.util.Mth;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
Expand Down Expand Up @@ -46,10 +45,11 @@ protected void onHit(HitResult result) {
EntityHitResult entityRayTrace = (EntityHitResult) result;
Entity target = entityRayTrace.getEntity();
if (target.isAlive()) {
target.hurt(DamageSource.thrown(this, this.getOwner()), Mth.nextInt(level.random, 4, 8));
if (!target.level.isClientSide && target.isOnFire() == false
//DamageSource.thrown(this, this.getOwner())
target.hurt(level.damageSources().thrown(this, this.getOwner()), Mth.nextInt(level.random, 4, 8));
if (!level.isClientSide && target.isOnFire() == false
&& target instanceof LivingEntity living) {
living.hurt(DamageSource.MAGIC, Mth.nextInt(level.random, 3, 5));
living.hurt(level.damageSources().magic(), Mth.nextInt(level.random, 3, 5));
living.addEffect(new MobEffectInstance(MobEffects.WITHER, Const.TICKS_PER_SEC * 5, 1));
}
}
Expand All @@ -65,7 +65,7 @@ else if (type == HitResult.Type.BLOCK) {
|| blockHere == Blocks.SNOW_BLOCK
|| blockHere == Blocks.SNOW
|| blockHere == Blocks.ICE) {
this.level.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
level.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
}
}
this.remove(RemovalReason.DISCARDED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.util.Mth;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
Expand Down Expand Up @@ -45,10 +44,10 @@ protected void onHit(HitResult result) {
EntityHitResult entityRayTrace = (EntityHitResult) result;
Entity target = entityRayTrace.getEntity();
if (target.isAlive()) {
target.hurt(DamageSource.thrown(this, this.getOwner()), Mth.nextInt(level.random, 2, 6));
target.hurt(level.damageSources().thrown(this, this.getOwner()), Mth.nextInt(level.random, 2, 6));
if (!target.level.isClientSide && target.isOnFire() == false
&& target instanceof LivingEntity) {
target.hurt(DamageSource.IN_FIRE, Mth.nextInt(level.random, 3, 5));
target.hurt(level.damageSources().inFire(), Mth.nextInt(level.random, 3, 5));
LivingEntity living = (LivingEntity) target;
living.addEffect(new MobEffectInstance(PotionEffectRegistry.STUN.get(), Const.TICKS_PER_SEC * 4, 1));
living.setSecondsOnFire(Mth.nextInt(level.random, 1, 5));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
Expand Down Expand Up @@ -56,7 +55,7 @@ protected void onHit(HitResult result) {
Entity target = entityRayTrace.getEntity();
if (target.isAlive() && target instanceof LivingEntity alive) {
alive.addEffect(new MobEffectInstance(PotionEffectRegistry.SWIMSPEED.get(), 60, 2));
target.hurt(DamageSource.thrown(this, this.getOwner()), 0);// zero damage for visuals and knockback
target.hurt(level.damageSources().thrown(this, this.getOwner()), 0);// zero damage for visuals and knockback
}
}
else if (type == HitResult.Type.BLOCK) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LightningBolt;
Expand Down Expand Up @@ -40,7 +39,7 @@ protected void onHit(HitResult result) {
EntityHitResult entityRayTrace = (EntityHitResult) result;
Entity target = entityRayTrace.getEntity();
if (target.isAlive()) {
target.hurt(DamageSource.thrown(this, this.getOwner()), 0);
target.hurt(level.damageSources().thrown(this, this.getOwner()), 0);
// LightningBoltEntity lightningboltentity = new LightningBoltEntity(world, target.getPosX(), target.getPosY(), target.getPosZ(), false);
LightningBolt lightningboltentity = EntityType.LIGHTNING_BOLT.create(level);
lightningboltentity.moveTo(target.getX(), target.getY(), target.getZ());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.util.Mth;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
Expand Down Expand Up @@ -44,8 +43,8 @@ protected void onHit(HitResult result) {
EntityHitResult entityRayTrace = (EntityHitResult) result;
Entity target = entityRayTrace.getEntity();
if (target.isAlive() && target instanceof LivingEntity) {
target.hurt(DamageSource.thrown(this, this.getOwner()), Mth.nextInt(level.random, 2, 5));
target.hurt(DamageSource.DRY_OUT, Mth.nextInt(level.random, 2, 3));
target.hurt(level.damageSources().thrown(this, this.getOwner()), Mth.nextInt(level.random, 2, 5));
target.hurt(level.damageSources().dryOut(), Mth.nextInt(level.random, 2, 3));
LivingEntity living = (LivingEntity) target;
living.addEffect(new MobEffectInstance(PotionEffectRegistry.STUN.get(), 60, 1));
// if (world.isAirBlock(living.getPosition()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private void attemptTeleport(Level worldIn, Player playerIn, ItemStack held) {
BlockPos pos;
boolean needsTeleport = false;
if (optional.isPresent()) {
pos = new BlockPos(optional.get().x(), optional.get().y(), optional.get().z());
pos = new BlockPos((int) optional.get().x(), (int) optional.get().y(), (int) optional.get().z());
ResourceKey<Level> spawnWorldKey = serverPlayerEntity.getRespawnDimension();
ServerLevel spawnWorld = worldIn.getServer().getLevel(spawnWorldKey);
if (spawnWorld != null && spawnWorldKey == Level.NETHER) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class GlowingHelmetItem extends ArmorItem implements IHasClickToggle {

public static final String NBT_STATUS = "onoff";

public GlowingHelmetItem(ArmorMaterial materialIn, EquipmentSlot slot, Properties builderIn) {
public GlowingHelmetItem(ArmorMaterial materialIn, ArmorItem.Type slot, Properties builderIn) {
super(materialIn, slot, builderIn);
}

Expand Down
Loading

0 comments on commit 0e38d1d

Please sign in to comment.