0
0
mirror of https://github.com/Wurst-Imperium/Wurst7.git synced 2024-09-20 01:12:13 +02:00

Add AntiCactusHack

This commit is contained in:
Alexander01998 2019-08-25 18:36:26 +02:00
parent bded4acc69
commit 5136e7a80f
5 changed files with 147 additions and 1 deletions

View File

@ -0,0 +1,48 @@
/*
* Copyright (C) 2014 - 2019 | Wurst-Imperium | All rights reserved.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.events;
import java.util.ArrayList;
import net.minecraft.util.shape.VoxelShape;
import net.wurstclient.event.Event;
import net.wurstclient.event.Listener;
public interface CactusCollisionShapeListener extends Listener
{
public void onCactusCollisionShape(CactusCollisionShapeEvent event);
public static class CactusCollisionShapeEvent
extends Event<CactusCollisionShapeListener>
{
private VoxelShape collisionShape;
public VoxelShape getCollisionShape()
{
return collisionShape;
}
public void setCollisionShape(VoxelShape collisionShape)
{
this.collisionShape = collisionShape;
}
@Override
public void fire(ArrayList<CactusCollisionShapeListener> listeners)
{
for(CactusCollisionShapeListener listener : listeners)
listener.onCactusCollisionShape(this);
}
@Override
public Class<CactusCollisionShapeListener> getListenerType()
{
return CactusCollisionShapeListener.class;
}
}
}

View File

@ -24,7 +24,7 @@ public final class HackList implements UpdateListener
{
// public final AntiAfkHack antiAfkHack = new AntiAfkHack();
// public final AntiBlindHack antiBlindHack = new AntiBlindHack();
// public final AntiCactusHack antiCactusHack = new AntiCactusHack();
public final AntiCactusHack antiCactusHack = new AntiCactusHack();
// public final AntiFireHack antiFireHack = new AntiFireHack();
// public final AntiKnockbackHack antiKnockbackHack = new
// AntiKnockbackHack();

View File

@ -0,0 +1,44 @@
/*
* Copyright (C) 2014 - 2019 | Wurst-Imperium | All rights reserved.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.hacks;
import net.minecraft.util.shape.VoxelShapes;
import net.wurstclient.Category;
import net.wurstclient.SearchTags;
import net.wurstclient.events.CactusCollisionShapeListener;
import net.wurstclient.hack.Hack;
@SearchTags({"NoCactus", "anti cactus", "no cactus"})
public final class AntiCactusHack extends Hack
implements CactusCollisionShapeListener
{
public AntiCactusHack()
{
super("AntiCactus", "Protects you from cactus damage.");
setCategory(Category.BLOCKS);
}
@Override
protected void onEnable()
{
WURST.getEventManager().add(CactusCollisionShapeListener.class, this);
}
@Override
protected void onDisable()
{
WURST.getEventManager().remove(CactusCollisionShapeListener.class,
this);
}
@Override
public void onCactusCollisionShape(CactusCollisionShapeEvent event)
{
event.setCollisionShape(VoxelShapes.fullCube());
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2014 - 2019 | Wurst-Imperium | All rights reserved.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.mixin;
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.CallbackInfoReturnable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CactusBlock;
import net.minecraft.entity.EntityContext;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.wurstclient.WurstClient;
import net.wurstclient.event.EventManager;
import net.wurstclient.events.CactusCollisionShapeListener.CactusCollisionShapeEvent;
@Mixin(CactusBlock.class)
public abstract class CactusBlockMixin extends Block
{
private CactusBlockMixin(WurstClient wurst, Settings block$Settings_1)
{
super(block$Settings_1);
}
@Inject(at = {@At("HEAD")},
method = {
"getCollisionShape(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/EntityContext;)Lnet/minecraft/util/shape/VoxelShape;"},
cancellable = true)
private void onGetCollisionShape(BlockState blockState_1,
BlockView blockView_1, BlockPos blockPos_1,
EntityContext entityContext_1, CallbackInfoReturnable<VoxelShape> cir)
{
EventManager events = WurstClient.INSTANCE.getEventManager();
if(events == null)
return;
CactusCollisionShapeEvent event = new CactusCollisionShapeEvent();
events.fire(event);
VoxelShape collisionShape = event.getCollisionShape();
if(collisionShape != null)
cir.setReturnValue(collisionShape);
}
}

View File

@ -8,6 +8,7 @@
"BlockEntityRenderDispatcherMixin",
"BlockMixin",
"BlockStateMixin",
"CactusBlockMixin",
"ChatHudMixin",
"ChunkOcclusionGraphBuilderMixin",
"ClientConnectionMixin",